Overview
mcp-agent is a Python framework for building AI agents using the Model Context Protocol (MCP). It implements patterns from Anthropic’s Building Effective Agents guide and provides integration with any MCP-compatible server. The framework handles:- MCP server lifecycle management and connections
- Agent workflow patterns (parallel, routing, orchestration, etc.)
- Multi-agent coordination
- Integration with multiple LLM providers
- Deployment as MCP servers
Key Features
MCP Protocol Support
- Connect to any MCP server via stdio, SSE, WebSocket, or HTTP
- Access tools, resources, prompts, and file system roots
- Automatic tool discovery and integration
- Sampling, elicitation, and notifications
Agent Patterns
Implementation of all patterns from Anthropic’s research:- Parallel Processing - Fan-out tasks to multiple agents
- Routing - Intelligent request routing
- Orchestrator-Workers - Plan and execute complex tasks
- Evaluator-Optimizer - Iterative improvement
- Intent Classification - Understand user intent
- Swarm - Multi-agent collaboration
- Deep Orchestrator - Adaptive planning with knowledge extraction
Execution Engines
- asyncio - In-memory execution for development and simple deployments
- Temporal - Durable execution with automatic retries, pause/resume, and workflow history
LLM Support
Works with:- OpenAI (GPT-4, GPT-4o)
- Anthropic (Claude 3, Claude 3.5)
- Google (Gemini)
- Azure OpenAI
- AWS Bedrock
- Local models via Ollama
Quick Example
main.py
Example Applications
Explore working examples in the examples directory:- Agent as MCP Server: Deploy agents as MCP servers for Claude Desktop integration (examples/mcp_agent_server)
- Workflow Patterns: All patterns from Anthropic’s Building Effective Agents guide (examples/workflows)
- Basic Agents: Simple agent examples with various MCP servers (examples/basic)
- Temporal Integration: Durable workflow execution examples (examples/temporal)
- Model Providers: Examples for OpenAI, Anthropic, Google, Azure, Bedrock (examples/model_providers)
Installation
Using uv (recommended):Configuration
mcp-agent uses two configuration files: mcp_agent.config.yaml - Application configuration:mcp_agent.config.yaml
mcp_agent.secrets.yaml
Project Structure
Deployment Options
Local Development
Run agents locally with asyncio execution engine for rapid development.Production with Temporal
Use Temporal for durable execution, automatic retries, and workflow management.As a MCP Server
Expose your agents as MCP servers that can be used by Claude Desktop, VS Code, or other MCP clients.mcp-agent cloud
Deploy agents to managed cloud infrastructure with one command.Examples
The examples directory contains 30+ working examples:- Basic agents - Simple patterns and MCP server usage
- Workflow patterns - All patterns from Anthropic’s guide
- Integrations - Claude Desktop, Streamlit, Jupyter
- MCP servers - Agents exposed as MCP servers
- Temporal - Durable execution examples
Next Steps
- Installation - Set up your development environment
- Quick Start - Build your first agent
- Core Concepts - Understand agents, workflows, and MCP
- Examples - Learn from working code
Resources
- Model Context Protocol - MCP specification
- Building Effective Agents - Anthropic’s guide
- GitHub Repository - Source code
- Discord Community - Get help and discuss