Esta página se muestra en inglés. Una traducción al español está en curso.
MCP ConfigsMar 31, 2026·2 min de lectura

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

Listo para agents

Staging seguro para este activo

Este activo primero queda en staging. El prompt copiado pide inspeccionar los archivos staged antes de activar scripts, config MCP o config global.

Stage only · 17/100Política: staging
Superficie agent
Cualquier agent MCP/CLI
Tipo
Mcp Config
Instalación
Stage only
Confianza
Confianza: Established
Entrada
mcp-agent — Build AI Agents with MCP Patterns
Comando de staging seguro
npx -y tokrepo@latest install 47de10df-654b-43b4-8869-8629119e532d --target codex

Primero deja archivos en staging; la activación requiere revisar el README y el plan staged.

TL;DR
mcp-agent provides composable workflow patterns like orchestrator, map-reduce, and evaluator-optimizer for building MCP-based agents.
§01

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.

§02

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.

§03

How to use

  1. 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]'
  1. 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')
  1. 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']
)
§04

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')
§05

Related on TokRepo

§06

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.

Preguntas frecuentes

What workflow patterns does mcp-agent support?+

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.

Does mcp-agent require MCP servers?+

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.

Which LLM providers are supported?+

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].

How does the evaluator-optimizer pattern work?+

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.

Can I combine multiple workflow patterns?+

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.

Referencias (3)
🙏

Fuente y agradecimientos

Created by LastMile AI. Licensed under MIT. lastmile-ai/mcp-agent — 8,200+ GitHub stars

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados