Skip to main content
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.

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

  1. Error Handling: Always include proper error handling for MCP server connections and operations.
  2. Resource Cleanup: Remember to close the connection to the MCP server when using MCPTools or MultiMCPTools:
  1. 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.