> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP

> Connect to any MCP server as a context provider.

Connect to any MCP (Model Context Protocol) server. The provider wraps the server's tools in a sub-agent, exposing them as `query_mcp_<name>`.

```python theme={null}
from agno.agent import Agent
from agno.context.mcp import MCPContextProvider

github = MCPContextProvider(
    server_name="github",
    transport="stdio",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-github"],
)

await github.asetup()

agent = Agent(
    model=...,
    tools=github.get_tools(),
)

await agent.arun("List my recent pull requests")
await github.aclose()
```

> [!NOTE]
>
> MCPContextProvider is **read-only** by default. The tool name includes the server name: `query_mcp_github`.

## Transport Options

> [tab] stdio
>
> Run a local process.
>
> ```python theme={null}
> mcp = MCPContextProvider(
>     server_name="github",
>     transport="stdio",
>     command="npx",
>     args=["-y", "@modelcontextprotocol/server-github"],
> )
> ```

> [tab] sse
>
> Connect to an SSE endpoint.
>
> ```python theme={null}
> mcp = MCPContextProvider(
>     server_name="my-server",
>     transport="sse",
>     url="http://localhost:8080/sse",
> )
> ```

> [tab] streamable-http
>
> Connect to an HTTP endpoint with streaming.
>
> ```python theme={null}
> mcp = MCPContextProvider(
>     server_name="my-server",
>     transport="streamable-http",
>     url="http://localhost:8080/mcp",
>     headers={"Authorization": "Bearer ..."},
> )
> ```

## Configuration

| Parameter | Type | Default | Description |
| - | - | - | - |
| `server_name` | `str` | required | Name of the MCP server. Used in tool name. |
| `transport` | `str` | required | `"stdio"`, `"sse"`, or `"streamable-http"`. |
| `command` | `str` | `None` | Command to run (stdio transport). |
| `args` | `list[str]` | `None` | Command arguments (stdio transport). |
| `url` | `str` | `None` | Server URL (sse/http transports). |
| `headers` | `dict` | `None` | HTTP headers (sse/http transports). |
| `env` | `dict` | `None` | Environment variables for the subprocess. |
| `timeout_seconds` | `int` | `30` | Connection timeout. |
| `id` | `str` | `"mcp_<name>"` | Tool becomes `query_<id>`. |
| `model` | `Model` | `None` | Model for the sub-agent. |

## Tools Exposed

| Tool | Description |
| - | - |
| `query_mcp_<name>` | Query the MCP server. Sub-agent calls the server's tools internally. |

## Lifecycle Management

MCPContextProvider **requires** explicit setup and teardown:

```python theme={null}
mcp = MCPContextProvider(...)

await mcp.asetup()   # Connect to server
try:
    # Use the provider
    agent = Agent(model=..., tools=mcp.get_tools())
    await agent.arun("...")
finally:
    await mcp.aclose()  # Disconnect
```

## Resources

> [card] [MCPTools Reference](https://agno-v2.mintlify.site/tools/mcp/overview.md)
>
> MCP tools and server setup

> [card] [MCP Servers](https://github.com/modelcontextprotocol/servers)
>
> Available MCP servers


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.