Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose mcp-agent apps (MCPApp) as MCP servers #112

Merged
merged 9 commits into from
Apr 4, 2025

Conversation

saqadri
Copy link
Collaborator

@saqadri saqadri commented Apr 3, 2025

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:

  1. create_mcp_server_for_app function - Creates an MCP server for any MCPApp instance, exposing workflows and agents as tools
  2. FastMCPApp class - Extends MCPApp with declarative agent creation using decorators
  3. Server endpoint architecture - Provides standardized patterns for workflow and agent interactions

Key Features

Server Architecture

  • Workflow-related endpoints:

    • workflows/list - Lists available workflows with detailed information
    • workflows/run - Schedules workflow execution and returns a workflow ID
    • workflows/get_status - Retrieves current workflow status
    • workflows/cancel - Terminates a running workflow
    • Per-workflow endpoints: workflows/{workflow_name}/run for direct access
  • Agent-related endpoints:

    • agents/list - Lists available agents with detailed information
    • agents/generate, agents/generate_str, agents/generate_structured - Generic agent interaction
    • Per-agent endpoints: agents/{agent_name}/generate* for direct access

Declarative 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 agent

Current Limitations

  • Only works with asyncio (Temporal support needed)
  • Tracing and observability need improvement
  • Some edge cases in workflow tracking need handling

Future Work

  • Integration with Temporal for production-grade workflow execution
  • Enhanced logging and tracing throughout the server lifecycle
  • Comprehensive error handling and recovery mechanisms
  • More structured schema definitions for endpoint inputs/outputs

@saqadri saqadri merged commit c788179 into feature/agentcloud Apr 4, 2025
4 checks passed
@saqadri
Copy link
Collaborator Author

saqadri commented Apr 4, 2025

Feel free to comment on the PR, will track it. Merging into parent feature branch to continue building on top of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant