Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agno.com/llms.txt

Use this file to discover all available pages before exploring further.

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>.
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()
MCPContextProvider is read-only by default. The tool name includes the server name: query_mcp_github.

Transport Options

Run a local process.
mcp = MCPContextProvider(
    server_name="github",
    transport="stdio",
    command="npx",
    args=["-y", "@modelcontextprotocol/server-github"],
)

Configuration

ParameterTypeDefaultDescription
server_namestrrequiredName of the MCP server. Used in tool name.
transportstrrequired"stdio", "sse", or "streamable-http".
commandstrNoneCommand to run (stdio transport).
argslist[str]NoneCommand arguments (stdio transport).
urlstrNoneServer URL (sse/http transports).
headersdictNoneHTTP headers (sse/http transports).
envdictNoneEnvironment variables for the subprocess.
timeout_secondsint30Connection timeout.
idstr"mcp_<name>"Tool becomes query_<id>.
modelModelNoneModel for the sub-agent.

Tools Exposed

ToolDescription
query_mcp_<name>Query the MCP server. Sub-agent calls the server’s tools internally.

Lifecycle Management

MCPContextProvider requires explicit setup and teardown:
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

MCPTools Reference

MCP tools and server setup

MCP Servers

Available MCP servers