Expose mcp-agent apps (MCPApp) as MCP servers #112
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds server capabilities to mcp-agent applications, allowing workflows and agents to be exposed as API endpoints via a new server abstraction. The motivation for this is to enable mcp-agent apps to be easily integrated into any MCP-compatible client application.
mcp_agent_as_server3.mov
It introduces three key components:
create_mcp_server_for_app
function - Creates an MCP server for any MCPApp instance, exposing workflows and agents as toolsFastMCPApp
class - Extends MCPApp with declarative agent creation using decoratorsKey Features
Server Architecture
Workflow-related endpoints:
workflows/list
- Lists available workflows with detailed informationworkflows/run
- Schedules workflow execution and returns a workflow IDworkflows/get_status
- Retrieves current workflow statusworkflows/cancel
- Terminates a running workflowworkflows/{workflow_name}/run
for direct accessAgent-related endpoints:
agents/list
- Lists available agents with detailed informationagents/generate
,agents/generate_str
,agents/generate_structured
- Generic agent interactionagents/{agent_name}/generate*
for direct accessDeclarative Agent Creation
FastMCPApp
introduces decorators for defining various agent types:@app.agent
- Basic agent configuration@app.parallel
- Fan-out/fan-in workflow agents@app.orchestrator
- Coordinating workflow agent@app.router
- Request routing workflow agent@app.evaluator_optimizer
- Quality assurance workflow agentCurrent Limitations
Future Work