Skip to main content
Turn the default MCP surface off and serve agents directly as tools. A bare agent in MCPConfig(tools=[…]) becomes a tool named after its id with the agent’s own description; agent.as_tool(name=…, description=…) publishes it under a model-facing name and pitch of your choosing instead. An MCP client sees chief and deep_research — not run_agent(agent_id=…) — and each call runs through the same machinery as the default run tools (fresh session minting, scope checks, progress). continue_run and cancel_run ride along automatically so paused (human-in-the-loop) runs stay resumable; set lifecycle_tools=False to serve exactly the configured tools.
agents_as_tools.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Run the example

Save the code above as agents_as_tools.py, then run:
Full source: cookbook/05_agent_os/14_mcp/agents_as_tools.py