Connect your agents to external tools and data using the Model Context Protocol (MCP).
MCPServerStdio: For Command-Line Tools
MCPServerSse: For Web Service Tools
MCPServerStreamableHttp: For HTTP Streaming Tools
mcp_servers
list during initialization. Agency Swarm then automatically discovers the tools offered by the server and makes them available to the agent under the name
you specified (e.g., Filesystem_Server.list_files
).
Follow these steps:
Step 1: Define Stdio Server Connection (e.g., Filesystem)
MCPServerStdio
to run the standard MCP filesystem tool using npx
.Step 2: Define SSE Server Connection (Optional)
MCPServerSse
to connect to a hypothetical web server running locally that provides tools via SSE.Step 3: Define Streamable HTTP Server Connection (Optional)
MCPServerStreamableHttp
to connect to a web server that implements the Streamable HTTP transport protocol.Step 4: Initialize Agent with Servers
mcp_servers
parameter when creating your Agent
.MCPServerStdio
and MCPServerSse
, see the demo_mcp.py
script located in the tests/demos/
directory of the Agency Swarm repository.
MCPServerStdio
for command-line tool servers, MCPServerSse
for SSE-based web servers, and MCPServerStreamableHttp
for HTTP streaming servers.name
, params
, and optionally configuring strict
and cache_tools_list
.Agent
’s mcp_servers
parameter during initialization.name
you give a server connection becomes the prefix for its tools (e.g., MyServerName.tool_name
).