Skip to main content
Create one MCPTools instance per server and pass every instance to the agent.

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.

Connect multiple servers

multiple_mcp_servers.py

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.