What is mcp-agent?
mcp-agent is a Python framework for building AI agents using the Model Context Protocol (MCP). It provides a simple, composable way to build effective agents by combining standardized MCP servers with proven workflow patterns.Anatomy of an MCP Agent
The quickest way to internalise the stack is to walk through the basic finder agent. Each step maps directly to a core SDK concept:1. Configure servers and models
mcp_agent.config.yaml
2. Bootstrap the application
main.py
MCPApp loads the config/secrets, prepares logging and tracing, and manages server connections.
3. Describe the agent
finder_agent.py
async with finder: runs, the agent initialises those connections via the app’s server registry.
4. Attach an augmented LLM
fetch, read_text_file, etc.) during generation.
5. Run inside the app context
app.run(). From here, layer in more sophisticated patterns:
- Need persistent connections? Check out the mcp_server_aggregator example.
- Want OAuth-protected servers? Follow the OAuth basic agent walkthrough.
- Ready for orchestration? Browse the workflow gallery and the Temporal projects.
Core Architecture
mcp-agent consists of four main layers:MCP Integration
Connect to any MCP server and automatically discover tools, resources, and prompts
Agent Layer
Agents that combine instructions with MCP server capabilities
LLM Integration
Augmented LLMs that can use tools and maintain conversation context
Workflow Patterns
Composable patterns for orchestrating agents and tasks
Key Components
MCPApp
TheMCPApp is the central application context that manages configuration, logging, and server connections:
Agents
Agents are entities with specific instructions and access to MCP servers:AugmentedLLM
AugmentedLLMs are LLMs enhanced with tools from MCP servers:MCP Servers
MCP servers provide tools, resources, and other capabilities to agents:mcp_agent.config.yaml
Workflows
Workflows are composable patterns for orchestrating agents:Execution Engines
Execution engines determine how workflows run:- asyncio: In-memory execution for development
- Temporal: Durable execution with pause/resume capabilities
mcp_agent.config.yaml
Workflow Patterns
mcp-agent implements all patterns from Anthropic’s Building Effective Agents:Parallel
Fan-out tasks to multiple agents
Router
Intelligent request routing
Intent Classifier
Understand user intent
Planner
Plan and execute complex tasks
Deep Research
Adaptive planning with knowledge extraction
Evaluator-Optimizer
Iterative improvement with LLM-as-judge
Swarm
Multi-agent collaboration
Model Context Protocol
mcp-agent provides full support for MCP capabilities:Tools
Execute functions and produce side effects
Resources
Access data and load context
Prompts
Reusable templates for interactions
Sampling
Request LLM completions from clients
