/ Каталог / Песочница / mcp-agent
● Сообщество lastmile-ai ⚡ Сразу

mcp-agent

автор lastmile-ai · lastmile-ai/mcp-agent

Production-grade agent patterns (Orchestrator, Router, Evaluator, Swarm) on top of MCP — with optional Temporal durability.

mcp-agent from lastmile-ai is a Python framework for composing MCP-based agents using proven patterns: Parallel, Router, Intent Classifier, Orchestrator-Workers, Deep Research, Evaluator-Optimizer, Swarm. Same API whether you run on asyncio or Temporal for durable execution.

Зачем использовать

Ключевые функции

Живое демо

Как выглядит на практике

mcp-agent.replay ▶ готово
0/0

Установка

Выберите клиент

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "mcp-agent": {
      "command": "uvx",
      "args": [
        "mcp-agent"
      ]
    }
  }
}

Откройте Claude Desktop → Settings → Developer → Edit Config. Перезапустите после сохранения.

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "mcp-agent": {
      "command": "uvx",
      "args": [
        "mcp-agent"
      ]
    }
  }
}

Cursor использует ту же схему mcpServers, что и Claude Desktop. Конфиг проекта приоритетнее глобального.

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "mcp-agent": {
      "command": "uvx",
      "args": [
        "mcp-agent"
      ]
    }
  }
}

Щёлкните значок MCP Servers на боковой панели Cline, затем "Edit Configuration".

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "mcp-agent": {
      "command": "uvx",
      "args": [
        "mcp-agent"
      ]
    }
  }
}

Тот же формат, что и Claude Desktop. Перезапустите Windsurf для применения.

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "mcp-agent",
      "command": "uvx",
      "args": [
        "mcp-agent"
      ]
    }
  ]
}

Continue использует массив объектов серверов, а не map.

~/.config/zed/settings.json
{
  "context_servers": {
    "mcp-agent": {
      "command": {
        "path": "uvx",
        "args": [
          "mcp-agent"
        ]
      }
    }
  }
}

Добавьте в context_servers. Zed перезагружается автоматически.

claude mcp add mcp-agent -- uvx mcp-agent

Однострочная команда. Проверить: claude mcp list. Удалить: claude mcp remove.

Сценарии использования

Реальные сценарии: mcp-agent

Build an orchestrator-workers agent for research tasks

👤 Python devs building multi-step agents ⏱ ~60 min advanced

Когда использовать: The task is too big for one LLM pass but decomposes into parallel subtasks (e.g., research 10 competitors).

Предварительные требования
  • Python 3.10+ — standard
  • MCP servers you want the agent to use — List them in the mcp-agent config
Поток
  1. Define worker agents
    Create 2 Agents — scraper with the firecrawl server, writer with filesystem. Give each a focused instruction set.✓ Скопировано
    → Two Agent instances
  2. Wire the orchestrator
    Wrap them with create_orchestrator(planner_llm=..., workers=[scraper, writer]). Max iterations = 10.✓ Скопировано
    → Orchestrator returns plan + execution handle
  3. Run a real task
    Run: 'Research the 5 top-rated Postgres MCPs on GitHub. For each, write a 1-page summary to ./reports/<slug>.md.'✓ Скопировано
    → 5 files generated with coherent content

Итог: A parallelized agent that completes what would be 30 min of manual multi-step work in 3-5 min.

Подводные камни
  • Orchestrator creates too many or too few subtasks — Give the planner LLM explicit guidance: 'break into 3-7 subtasks, each <5 minutes of work'
  • Workers re-fetch the same data — Share a cache via the app state or pass results explicitly through the plan
Сочетать с: mcp-use · fastmcp

Build an evaluator-optimizer agent for high-quality writing

👤 Teams shipping content pipelines ⏱ ~45 min advanced

Когда использовать: First-draft LLM output is too sloppy for production. You need an automatic 'keep iterating until it passes' loop.

Поток
  1. Define the writer and evaluator
    Writer: produces a draft given a brief. Evaluator: scores on [accuracy, clarity, tone] 1-5, with rationale.✓ Скопировано
    → Two agents defined
  2. Set the loop
    Use EvaluatorOptimizer with min_rating=4 across all criteria, max_iterations=5. Pass brief as input.✓ Скопировано
    → Loop runs, iterations visible in logs
  3. Observe convergence
    For 10 diverse briefs, log: initial score, final score, iterations needed. Are there briefs that never converge?✓ Скопировано
    → Stats with outliers identified

Итог: Consistent-quality output without human review in the loop.

Подводные камни
  • Evaluator is lenient, loop exits on iter 1 with mediocre output — Calibrate the evaluator — give it 3 example inputs with expected scores in the system prompt
  • Budget blows up when max_iterations is high — Cap at 3-4; if it doesn't converge by then, the brief is the problem, not the model

Make an agent workflow durable with Temporal

👤 Platform engineers running agents in production ⏱ ~90 min advanced

Когда использовать: Your agent flow is long-running (minutes to hours), can't afford to restart from zero if a node dies.

Предварительные требования
  • Running Temporal clustertemporal server start-dev for local, Temporal Cloud or self-hosted for prod
Поток
  1. Annotate workflows
    Decorate my existing orchestrator function with @app.workflow and individual steps with @app.workflow_task.✓ Скопировано
    → Workflow registered with Temporal
  2. Switch the executor
    Change the app config executor: 'temporal'. Register the worker. Start a workflow.✓ Скопировано
    → Temporal UI shows the running workflow
  3. Verify crash recovery
    Kill the Python worker mid-workflow. Restart it. Confirm the workflow resumes from the last completed activity.✓ Скопировано
    → No duplicate work, no lost state

Итог: Agent workflows survive process restarts, deploys, and OOMs — critical for hour-long research tasks.

Подводные камни
  • Activities aren't idempotent and resume causes double-writes — Every activity must be safe to retry — use idempotency keys on external writes

Комбинации

Сочетайте с другими MCP — эффект x10

mcp-agent + mcp-use

mcp-use for client plumbing + mcp-agent for workflow patterns

Use mcp-use to connect filesystem + git. Wrap with mcp-agent's Orchestrator to plan a multi-repo refactor.✓ Скопировано
mcp-agent + fastmcp

Build custom MCPs with FastMCP that your mcp-agent workflows consume

Expose our internal ranking API via FastMCP, then use it in an mcp-agent Router that classifies customer questions.✓ Скопировано

Инструменты

Что предоставляет этот MCP

ИнструментВходные данныеКогда вызыватьСтоимость
MCPApp config_path or config object Top-level — one per process free
Agent(name, instruction, server_names) configured with which MCP servers it can use Define each worker/role free
AugmentedLLM.generate / generate_str / generate_structured messages, optional schema Direct LLM call with MCP tools wired LLM tokens
create_parallel_llm / create_router_llm / create_orchestrator agents + planner LLM Instantiate one of the built-in patterns LLM tokens × pattern fan-out
@app.workflow / @app.workflow_task decorator on async function When using Temporal executor free
EvaluatorOptimizer writer_agent, evaluator_agent, min_rating, max_iterations Quality-critical outputs expensive — cap max_iterations

Стоимость и лимиты

Во что обходится

Квота API
None from mcp-agent; LLM + MCP costs passthrough
Токенов на вызов
Patterns amplify — a Parallel with 5 workers is 5× the tokens of a single LLM call
Деньги
Free library; LLM + optional Temporal infra are real costs
Совет
Patterns like Orchestrator fan out — put an explicit token budget check in the planner LLM's system prompt

Безопасность

Права, секреты, радиус поражения

Хранение учётных данных: env vars for LLM keys + per-MCP secrets
Исходящий трафик: LLM provider + each configured MCP server + Temporal (if enabled)

Устранение неполадок

Частые ошибки и исправления

Workflow hangs at start with no logs

MCP server failed to spawn. Enable debug logging: logger: {level: 'DEBUG'} in config. Usually a bad command/env in the server entry.

Orchestrator returns plan but no execution

You called .plan() instead of .generate(). Use the full method to execute the plan.

Temporal workflow fails with serialization error

Your activity returns a non-serializable object (e.g., an MCP client handle). Activities must return JSON-serializable values.

LLM ignores available tools and hallucinates

The system prompt is likely truncated or missing tool list. Upgrade to a tool-use-strong model (Sonnet, GPT-4o) and verify tools in list_tools before running.

Альтернативы

mcp-agent в сравнении

АльтернативаКогда использоватьКомпромисс
mcp-useYou want lighter client plumbing without the pattern libraryWrite orchestration code yourself
LangGraphYou want stateful graphs with time-travel debuggingMore LangChain-centric; MCP is bolted on
CrewAIYou want opinionated role-based agent crewsDifferent mental model; MCP support is secondary

Ещё

Ресурсы

📖 Читать официальный README на GitHub

🐙 Открытые задачи

🔍 Все 400+ MCP-серверов и Skills