Skip to main content
Agno’s MCP integration supports connecting an Agent to multiple MCP servers at once. There are two approaches to this:
  1. Using multiple MCPTools instances
  2. Using a single MultiMCPTools instance
MultiMCPTools is deprecated and will be removed in a future version. Use multiple MCPTools instances instead.

Prerequisites

1

Set up your virtual environment

Install the Python dependencies and Node.js, then verify the runtimes:
Export the keys used by the examples you run:
The @modelcontextprotocol/server-google-maps and @modelcontextprotocol/server-brave-search npm packages are deprecated and no longer supported. The snippets below document these legacy servers. Use maintained MCP servers for new projects.

Using multiple MCPTools instances

multiple_mcp_servers.py

Using a single MultiMCPTools instance

multiple_mcp_servers.py

Allowing partial failures with MultiMCPTools

If you are connecting to multiple MCP servers using the MultiMCPTools class, an error will be raised by default if connection to any MCP server fails. If you want to avoid raising in that case, you can set the allow_partial_failure parameter to True. This is useful if you are connecting to MCP servers that are not always available, and don’t want to exit your program if one of the servers is not available.

Avoiding tool name collisions

When using multiple MCP servers, you may encounter tool name collisions. This often happens when the same tool is available in multiple of the servers you are using. To avoid this, you can use the tool_name_prefix parameter. This will add the given prefix to all tool names coming from the MCPTools instance.