Learn how to use MCP with Agno to enable your agents to interact with external systems through a standardized interface.
The Model Context Protocol (MCP) enables Agents to interact with external systems through a standardized interface. You can connect your Agents to any MCP server, using Agno’s MCP integration.
Find the MCP server you want to use
You can use any working MCP server. To see some examples, you can check this GitHub repository, by the maintainers of the MCP themselves.
Initialize the MCP integration
Intialize the MCPTools
class as a context manager. The recommended way to define the MCP server, is to use the command
or url
parameters. With command
, you can pass the command used to run the MCP server you want. With url
, you can pass the URL of the running MCP server you want to use.
For example, to use the “mcp-server-git” server, you can do the following:
Provide the MCPTools to the Agent
When initializing the Agent, pass the MCPTools
class in the tools
parameter.
The agent will now be ready to use the MCP server:
Here’s a filesystem agent that uses the Filesystem MCP server to explore and analyze files:
You can also run MCP servers in the Agno Playground, which provides a web interface for interacting with your agents. Here’s an example of a GitHub agent running in the Playground:
Error Handling: Always include proper error handling for MCP server connections and operations.
Resource Cleanup: Use MCPTools
or MultiMCPTools
as an async context manager to ensure proper cleanup of resources:
Learn how to use MCP with Agno to enable your agents to interact with external systems through a standardized interface.
The Model Context Protocol (MCP) enables Agents to interact with external systems through a standardized interface. You can connect your Agents to any MCP server, using Agno’s MCP integration.
Find the MCP server you want to use
You can use any working MCP server. To see some examples, you can check this GitHub repository, by the maintainers of the MCP themselves.
Initialize the MCP integration
Intialize the MCPTools
class as a context manager. The recommended way to define the MCP server, is to use the command
or url
parameters. With command
, you can pass the command used to run the MCP server you want. With url
, you can pass the URL of the running MCP server you want to use.
For example, to use the “mcp-server-git” server, you can do the following:
Provide the MCPTools to the Agent
When initializing the Agent, pass the MCPTools
class in the tools
parameter.
The agent will now be ready to use the MCP server:
Here’s a filesystem agent that uses the Filesystem MCP server to explore and analyze files:
You can also run MCP servers in the Agno Playground, which provides a web interface for interacting with your agents. Here’s an example of a GitHub agent running in the Playground:
Error Handling: Always include proper error handling for MCP server connections and operations.
Resource Cleanup: Use MCPTools
or MultiMCPTools
as an async context manager to ensure proper cleanup of resources: