Overview
Any Upsonic Agent can be exposed as an MCP (Model Context Protocol) server usingas_mcp(). This lets other agents, tools, or MCP-compatible clients consume your agent over stdio, SSE, or Streamable HTTP.
Creating an MCP Server from an Agent
do tool that accepts a task string and returns the agent’s response.
Using an Agent MCP Server from Another Agent
MCPHandler spawns the server as a subprocess, discovers the do tool, and makes it available to the orchestrator agent.
Multiple Agent Servers as Tools
Usetool_name_prefix to avoid name collisions when combining multiple agent servers:
Customizing the Server
as_mcp() returns a standard FastMCP server object. You can add extra tools before running:
How It Works
as_mcp()creates aFastMCPserver named after the agent.- It registers a
dotool whose description includes the agent’srole,goal, andinstructions. - When a client calls
do(task="..."), the agent runs its full workflow internally (reasoning, tool use, memory) and returns the result as text. .run()starts the server and blocks, waiting for client connections.

