MCP Configs2026年3月31日·1 分钟阅读

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

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
Mcp Config
安装
Stage only
信任
信任等级:Established
入口
mcp-agent — Build AI Agents with MCP Patterns
安全暂存命令
npx -y tokrepo@latest install 47de10df-654b-43b4-8869-8629119e532d --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

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.

常见问题

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.

引用来源 (3)
🙏

来源与感谢

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产