> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.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.

Create one `MCPTools` instance per server and pass every instance to the agent.

## 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"
export BRAVE_API_KEY="your_brave_api_key_here"
```

> [!WARNING]
>
> 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.

## Connect multiple servers

```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()}?"
        )
    )
```

## 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())
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.