> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-himanshu-v3-tools-models-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Multiple MCP Servers

> Connect an Agent to multiple MCP servers with one MCPTools instance per server.

Agno's MCP integration supports connecting an Agent to multiple MCP servers at once: create one `MCPTools` instance per server and pass them all to the Agent.

<Warning>
  `MultiMCPTools` was removed in Agno v3.0. Importing it raises an `ImportError`; use one `MCPTools` instance per server, as below. Note that `env=` is per-instance — pass it to the server that needs it.
</Warning>

## Prerequisites

<Snippet file="create-venv-step.mdx" />

Install the Python dependencies and [Node.js](https://nodejs.org/en/download), then verify the runtimes:

```bash theme={null}
uv pip install -U "agno[mcp]" openai
node --version
npx --version
```

Export the keys used by the examples you run:

```bash theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
export GOOGLE_MAPS_API_KEY="your_google_maps_api_key_here"
```

<Warning>
  The `@modelcontextprotocol/server-google-maps` npm package is deprecated and no longer supported. The snippets below document this legacy server. Use maintained MCP servers for new projects.
</Warning>

## Using multiple `MCPTools` instances

```python multiple_mcp_servers.py theme={null}
import asyncio
import os
from datetime import date, timedelta

from agno.agent import Agent
from agno.tools.mcp import MCPTools


async def run_agent(message: str) -> None:
    """Run the Airbnb and Google Maps agent with the given message."""

    env = {
        **os.environ,
        "GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),
    }

    # Initialize and connect to multiple MCP servers
    airbnb_tools = MCPTools(command="npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt")
    google_maps_tools = MCPTools(command="npx -y @modelcontextprotocol/server-google-maps", env=env)
    await airbnb_tools.connect()
    await google_maps_tools.connect()

    try:
        agent = Agent(
            tools=[airbnb_tools, google_maps_tools],
            markdown=True,
        )

        await agent.aprint_response(message, stream=True)
    finally:
        await airbnb_tools.close()
        await google_maps_tools.close()


# Example usage
if __name__ == "__main__":
    check_in = date.today() + timedelta(days=30)
    check_out = check_in + timedelta(days=3)
    # Pull request example
    asyncio.run(
        run_agent(
            f"What listings are available in Cape Town for 2 people "
            f"from {check_in.isoformat()} to {check_out.isoformat()}?"
        )
    )
```

## Handling Connection Failures

`connect()` does not raise when a server is unreachable: it logs the error and leaves the instance uninitialized, so the Agent can still run with the servers that did connect. To fail fast when a server is required, check `initialized` after connecting:

```python theme={null}
await airbnb_tools.connect()
if not airbnb_tools.initialized:
    raise RuntimeError("Airbnb MCP server is unavailable")
```

Using `async with MCPTools(...)` as a context manager instead raises on connection failure.

## 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.

```python theme={null}
import asyncio

from agno.agent import Agent
from agno.tools.mcp import MCPTools


async def run_agent():
    # Development environment tools
    dev_tools = MCPTools(
        transport="streamable-http",
        url="https://docs.agno.com/mcp",
        # By providing this tool_name_prefix, all the tool names will be prefixed with "dev_"
        tool_name_prefix="dev",
    )
    await dev_tools.connect()

    agent = Agent(tools=[dev_tools])
    await agent.aprint_response("Which tools do you have access to? List them all.")

    await dev_tools.close()


if __name__ == "__main__":
    asyncio.run(run_agent())
```
