mcp-agent — Build AI Agents with MCP Patterns
mcp-agent is a Python framework for building AI agents using the Model Context Protocol. 8.2K+ GitHub stars. Implements composable workflow patterns (orchestrator, map-reduce, evaluator-optimizer, rou
Staging sûr pour cet actif
Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.
npx -y tokrepo@latest install 47de10df-654b-43b4-8869-8629119e532d --target codexStage les fichiers d'abord; l'activation exige la revue du README et du plan staged.
What it is
mcp-agent is a Python framework for building AI agents that leverage the Model Context Protocol (MCP). It implements composable workflow patterns including orchestrator, map-reduce, evaluator-optimizer, and router patterns. Each pattern is a reusable building block for constructing complex agent systems.
This framework targets developers building multi-step AI agents who want structured patterns rather than ad-hoc chains. If you need agents that fan out work, evaluate results, and iteratively improve, mcp-agent provides the scaffolding.
How it saves time or tokens
Instead of implementing agent orchestration patterns from scratch, mcp-agent provides tested, reusable implementations. The workflow provides pip install commands and shows how to compose patterns. You define what each step does; the framework handles execution order, result aggregation, and error handling.
How to use
- Install mcp-agent:
# With uv (recommended)
uv add 'mcp-agent[anthropic]'
# With pip
pip install 'mcp-agent[anthropic]'
# Multiple providers
uv add 'mcp-agent[openai,anthropic,google]'
- Define an agent with workflow patterns:
from mcp_agent import Agent, OrchestratorWorkflow
agent = Agent(
name='research-agent',
model='claude-sonnet-4-20250514',
tools=['web-search', 'file-reader']
)
workflow = OrchestratorWorkflow(
agents=[agent],
objective='Research and summarize the topic'
)
result = await workflow.run('Latest developments in quantum computing')
- Compose patterns for complex workflows:
from mcp_agent import MapReduceWorkflow, EvaluatorWorkflow
# Fan out research, then synthesize
research = MapReduceWorkflow(
map_agent=researcher,
reduce_agent=synthesizer,
inputs=['topic1', 'topic2', 'topic3']
)
Example
from mcp_agent import Agent, RouterWorkflow
# Route tasks to specialized agents
coder = Agent(name='coder', model='claude-sonnet-4-20250514', tools=['filesystem'])
writer = Agent(name='writer', model='claude-sonnet-4-20250514', tools=['web-search'])
router = RouterWorkflow(
agents=[coder, writer],
routing_strategy='llm', # LLM decides which agent handles each task
)
result = await router.run('Write a Python script that scrapes news headlines')
Related on TokRepo
- Multi-agent frameworks -- Compare multi-agent orchestration tools
- AI tools for agents -- Agent building frameworks and tools
Common pitfalls
- MCP server connections must be configured before running agents. Ensure your .mcp.json or environment variables point to running MCP servers.
- Map-reduce workflows multiply API costs by the number of map operations. Monitor token usage when fanning out to many parallel agents.
- The evaluator-optimizer pattern can loop indefinitely if the evaluation criteria are too strict. Set a max_iterations limit.
Questions fréquentes
mcp-agent supports orchestrator (single agent with tools), map-reduce (fan out and aggregate), evaluator-optimizer (iterative improvement loop), router (route tasks to specialized agents), and pipeline (sequential processing) patterns.
mcp-agent is designed around MCP but can also work with direct tool implementations. MCP servers provide the tool layer, but you can define tools as Python functions if you prefer not to use MCP.
mcp-agent supports Anthropic, OpenAI, Google, Azure, and AWS Bedrock through optional dependencies. Install with the appropriate extras like mcp-agent[anthropic] or mcp-agent[openai].
An agent generates output, then an evaluator agent scores it against criteria. If the score is below the threshold, the optimizer provides feedback and the generator tries again. This loops until the quality threshold is met or max iterations are reached.
Yes. Patterns are composable. You can use a router to dispatch tasks, each routed agent can use map-reduce internally, and the final output can go through an evaluator-optimizer for quality assurance.
Sources citées (3)
- mcp-agent GitHub— mcp-agent implements composable workflow patterns for MCP-based agents
- MCP Specification— Model Context Protocol for AI tool integration
- Anthropic Agent Patterns— Orchestrator, map-reduce, evaluator-optimizer patterns
En lien sur TokRepo
Source et remerciements
Created by LastMile AI. Licensed under MIT. lastmile-ai/mcp-agent — 8,200+ GitHub stars
Fil de discussion
Actifs similaires
mcp-use — Fullstack MCP Framework for AI Agents & Apps
Build MCP servers and apps for ChatGPT, Claude, and any LLM with TypeScript or Python SDK. Includes inspector, cloud deploy, and interactive widgets.
n8n MCP Server — Build Automations with AI, 1,396 Nodes
MCP server giving AI agents access to 1,396 n8n nodes and 2,709 workflow templates. Build and manage n8n automations through natural language.
Notte — Browser Automation MCP for AI Agents
MCP server that turns web browsers into AI agent tools. Notte provides structured browser actions like click, type, navigate, and extract for LLM-driven automation.
WhatsApp MCP Server — Chat with WhatsApp via AI Agents
MCP server connecting Claude and AI agents to your personal WhatsApp. Search contacts, read messages, send replies and media via natural language.