Agent(tools=[...]) is process boundaries. A tool that needs a database credential, a GPU, or a private network can live where those things are, and agents reach it over HTTP.
Prerequisites
Build it
1
Write the server
A Return a string, and make errors part of that string. An agent can reason about “Could not find data for bitcion”; it cannot reason about a traceback.
FastMCP server is a Python module with decorated functions. The decorator’s name and description are what the model sees, so write them for a reader who has no other context.2
Run it
http://localhost:8000/mcp. Leave it running.3
Point an agent at it
In a second terminal:Identical to every hosted-server example in this section — only the URL differs.
4
Inspect the server without an agent
When a tool call misbehaves, take the model out of the loop. If
MCPManager is the class the agent uses internally:call_tool returns what you expect and the agent still gets it wrong, the problem is the description or the prompt — not the server.Tuning a connection to a local server
MCPConnection gives you per-server timeouts and headers:
MCP tools plus your own Python tools
The two coexist on one agent — MCP tools come from the server, andtools_list_dictionary (or tools=[...]) adds your own:
An agent as a tool
The most interesting server in the examples folder wraps a whole swarmsAgent as a single MCP tool, so another agent — or any MCP client — can spawn and run it remotely:
Writing tools an agent can use well
Sources: examples/mcp/servers/ and examples/mcp/client/
Next
- MCPManager API — the full client surface: async calls, multi-server routing, caching.
- Model Context Protocol (MCP) — transports, OAuth, and error handling in depth.