Prerequisites
MCPDeployer needs mcp 2.0.0 or newer.
Build it
1
Write the server
The agent you want to share is an ordinary The tool is named after the agent:
Agent. agent_description becomes the tool description the calling model reads, so write it for a reader with no other context.server.py
Market-Analyst becomes market_analyst.2
Run it
3
Check it from a second terminal
/health is public:401:4
Call it from another agent
The client is an ordinary agent too. The portfolio manager discovers
MCPConnection carries the URL and the key.client.py
market_analyst, calls it with the question as task, and summarises what the analyst returned. The server terminal logs each request.What just happened
MCPDeployerwrappedanalystas one MCP tool with the schematask: str,img: str | None.- Every request to
/mcpwent through the auth layer first. The key can arrive asx-api-keyor asAuthorization: Bearer, which is whatMCPConnectionsends. - The tool call ran
analyst.run(task)on a worker thread and returned its answer as the tool result.
Variations
Keys from the environment instead of the code.api_key_env reads a comma-separated list, so you can rotate keys without a code change:
start() and stop(), or a with block, run it on a background thread:
Next
Serve a team from one server
Several agents, a workflow, and a function, each its own tool.
MCPDeployer reference
Every parameter, auth mode, and method.