Usage
1
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.
2
Initialize the MCP integration
Intialize the
MCPTools class and connect to the MCP server. This needs to be done inside an async function.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:3
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:Basic example: Filesystem Agent
Here’s a filesystem agent that uses the Filesystem MCP server to explore and analyze files:filesystem_agent.py
Using MCP in Agno Playground
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:github_playground.py
Best Practices
- Error Handling: Always include proper error handling for MCP server connections and operations.
-
Resource Cleanup: Remember to close the connection to the MCP server when using
MCPToolsorMultiMCPTools:
- Clear Instructions: Provide clear and specific instructions to your agent:
More Information
- Find examples of Agents that use MCP here.
- Find a collection of MCP servers here.
- Read the MCP documentation to learn more about the Model Context Protocol.
- Checkout the Agno Cookbook for more examples of Agents that use MCP.