Multi-server MCP setup
You’ll connect one agent to several MCP servers at once (a local git
server, a filesystem server and a hosted HTTP server) through a single
MCPRegistry. Use this pattern when the tools an agent needs are
spread across MCP servers; the registry connects them all, merges
their tool lists, and routes each call to the right server.
from loomflow import Agent
from loomflow.mcp import MCPRegistry, MCPServerSpec
registry = MCPRegistry([
MCPServerSpec.stdio(
name="git",
command="uvx",
args=["mcp-server-git", "--repository", "/Users/me/code/myrepo"],
),
MCPServerSpec.stdio(
name="fs",
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "/Users/me/workspace"],
),
MCPServerSpec.http(
name="hosted",
url="https://example.com/mcp/",
headers={"Authorization": "Bearer ..."},
),
])
agent = Agent(
"You are a developer assistant.",
model="claude-opus-4-7",
tools=registry,
)Tool names that are unique across servers keep their bare name. When
two servers expose the same name, both are registered under a
qualified server__tool name: if git and fs both had a status
tool, the agent would see git__status and fs__status (a double
underscore, because model providers reject . in tool names). The
qualified form is always accepted at call time, as is the dotted
git.status form earlier releases used, and the bare form is accepted
while it is unambiguous. The registry strips the prefix before
forwarding the call to the owning server.
To mix MCP tools with your own @tool functions, wrap both in an
ExtendedToolHost, as in the research agent
recipe.