Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

mcp-agent

> AI 编程
Open source

Build effective agents using Model Context Protocol and simple workflow patterns

8.5K stars0 likes3 views
WebsiteGitHub

About

Build effective agents using Model Context Protocol and simple workflow patterns

Build effective agents with Model Context Protocol using simple, composable patterns.

Examples | Building Effective Agents | MCP

Overview

mcp-agent is a simple, composable framework to build effective agents using Model Context Protocol.

[!Note] mcp-agent's vision is that MCP is all you need to build agents, and that simple patterns are more robust than complex architectures for shipping high-quality agents.

mcp-agent gives you the following:

  1. Full MCP support: It fully implements MCP, and handles the pesky business of managing the lifecycle of MCP server connections so you don't have to.
  2. Effective agent patterns: It implements every pattern described in Anthropic's Building Effective Agents in a composable way, allowing you to chain these patterns together.
  3. Durable agents: It works for simple agents and scales to sophisticated workflows built on Temporal so you can pause, resume, and recover without any API changes to your agent.

Altogether, this is the simplest and easiest way to build robust agent applications.

We welcome all kinds of contributions, feedback and your help in improving this project.

Minimal example

…

At a glance

Build an Agent

Connect LLMs to MCP servers in simple, composable patterns like map-reduce, orchestrator, evaluator-optimizer, router & more.

Quick Start ↗ | Docs ↗

Create any kind of MCP Server

Create MCP servers with a FastMCP-compatible API. You can even expose agents as MCP servers.

MCP Agent Server ↗ | Build a ChatGPT App ↗ | Examples ↗

Full MCP Support

Core: Tools ✅ Resources ✅ Prompts ✅ Notifications ✅
Advanced: OAuth ✅ Sampling ✅ Elicitation ✅ Roots ✅

Examples ↗ | MCP Docs ↗

Durable Execution (Temporal)

Scales to production workloads using Temporal as the agent runtime backend without any API changes.

Docs ↗ | Examples ↗

☁️ Deploy to Cloud

Beta: Deploy agents yourself, or use mcp-c for a managed agent runtime. All apps are deployed as MCP servers.

Demo ↗ | Cloud Quickstart ↗ | Examples ↗

Documentation & build with LLMs

mcp-agent's complete documentation is available at docs.mcp-agent.com, including full SDK guides, CLI reference, and advanced patterns. This readme gives a high-level overview to get you started.

  • llms-full.txt: contains entire documentation.
  • llms.txt: sitemap listing key pages in the docs.
  • docs MCP server

Table of Contents

  • Overview
  • Minimal example
  • Quickstart
  • Why mcp-agent
  • Core concepts
    • MCPApp
    • Agents & AgentSpec
    • Augmented LLM
    • Workflows & decorators
    • Configuration & secrets
    • MCP integration
  • Workflow patterns
  • CLI reference
  • Authentication
  • Advanced
    • Observability & controls
    • Composing workflows
    • Durable execution
    • Agent servers
    • Signals & human input
    • App configuration
    • Icons
    • MCP server management
  • Cloud deployment
  • Examples
  • FAQs
  • Community & contributions

Get Started

[!TIP] The CLI is available via uvx mcp-agent. To get up and running, scaffold a project with uvx mcp-agent init and deploy with uvx mcp-agent deploy my-agent.

You can get up and running in 2 minutes by running these commands:

bash
mkdir hello-mcp-agent && cd hello-mcp-agent
uvx mcp-agent init
uv init
uv add "mcp-agent[openai]"
# Add openai API key to `mcp_agent.secrets.yaml` or set `OPENAI_API_KEY`
uv run main.py

Installation

We recommend using uv to manage your Python projects (uv init).

bash
uv add "mcp-agent"

Alternatively:

bash
pip install mcp-agent

Also add optional packages for LLM providers (e.g. uv add "mcp-agent[openai, anthropic, google, azure, bedrock]").

Quickstart

[!TIP] The examples directory has several example applications to get started with. To run an example, clone this repo (or generate one with uvx mcp-agent init --template basic --dir my-first-agent)

bash
cd examples/basic/mcp_basic_agent # Or any other example
# Option A: secrets YAML
# cp mcp_agent.secrets.yaml.example mcp_agent.secrets.yaml && edit mcp_agent.secrets.yaml
uv run main.py

Here is a basic "finder" agent that uses the fetch and filesystem servers to look up a file, read a blog and write a tweet. Example link:

finder_agent.py
…
mcp_agent.config.yaml
…
Agent output

Why use mcp-agent?

There are too many AI frameworks out there already. But mcp-agent is the only one that is purpose-built for a shared protocol - MCP.mcp-agent pairs Anthropic’s Building Effective Agents patterns with a batteries-included MCP runtime so you can focus on behaviour, not boilerplate. Teams pick it because it is:

  • Composable – every pattern ships as a reusable workflow you can mix and match.
  • MCP-native – any MCP server (filesystem, fetch, Slack, Jira, FastMCP apps) connects without custom adapters.
  • Production ready – Temporal-backed durability, structured logging, token accounting, and Cloud deploys are first-class.
  • Pythonic – a handful of decorators and context managers wire everything together.

Docs: Welcome to mcp-agent • Effective patterns overview.

Core Components

Every project revolves around a single MCPApp runtime that loads configuration, registers agents and MCP servers, and exposes tools/workflows. The Core Components guide walks through these building blocks.

MCPApp

Initialises configuration, logging, tracing, and the execution engine so everything shares one context.

python
from mcp_agent.app import MCPApp

app = MCPApp(name="finder_app")

async def main():
    async with app.run() as running_app:
        logger = running_app.logger
        logger.info("App ready", data={"servers": list(running_app.context.server_registry.registry)})

Docs: MCPApp • Example: examples/basic/mcp_basic_agent.

Agents & AgentSpec

Agents couple instructions with the MCP servers (and optional functions) they may call. AgentSpec definitions can be loaded from disk and turned into agents or Augmented LLMs with the factory helpers.

python
from pathlib import Path
from mcp_agent.agents.agent import Agent
from mcp_agent.workflows.factory import load_agent_specs_from_file

agent = Agent(
    name="researcher",
    instruction="Research topics using web and filesystem access",
    server_names=["fetch", "filesystem"],
)

async with agent:
    tools = await agent.list_tools()

async with app.run() as running_app:
    specs = load_agent_specs_from_file(
        str(Path("examples/basic/agent_factory/agents.yaml")),
        context=running_app.context,
    )

Docs: Agents • Agent factory helpers • Examples: examples/basic/agent_factory.

Augmented LLM

Augmented LLMs wrap provider SDKs with the agent’s tools, memory, and structured output helpers. Attach one to an agent to unlock generate, generate_str, and generate_structured.

…

Docs: Augmented LLMs • Examples: examples/basic/mcp_basic_agent and the workflow projects listed in gallery.md.

Workflows & decorators

MCPApp decorators convert coroutines into durable workflows and tools. The same annotations work for both asyncio and Temporal execution.

python
from datetime import timedelta
from mcp_agent.executor.workflow import Workflow, WorkflowResult

@app.workflow
class PublishArticle(Workflow[WorkflowResult[str]]):
    @app.workflow_task(schedule_to_close_timeout=timedelta(minutes=5))
    async def draft(self, topic: str) -> str:
        return f"- intro to {topic}\n- highlights\n- next steps"

    @app.workflow_run
    async def run(self, topic: str) -> WorkflowResult[str]:
        outline = await self.draft(topic)
        return WorkflowResult(value=outline)

Docs: Decorator reference • Examples: examples/workflows.

Configu

Issues· 140 open

View all issuesOpen on GitHub
  • #766

    Document an opt-in Memcode memory workflow for MCP Agent

    Updated Sep 27, 2026
  • #765

    Add ScreenContextAgent to MCP integration examples

    Updated Sep 27, 2026
  • #764

    Interested in a free security test for mcp-agent?

    Updated Sep 24, 2026
  • #17

    Support MCP server prompts

    enhancementhelp wantedgood first issueUpdated Sep 8, 2026
  • #748

    docs: openai.base_url /v1 vs MCP_API_BASE_URL for hosted Chat Completions hosts

    Updated Sep 8, 2026
  • #209

    Configurable max tool response size

    enhancementUpdated Sep 6, 2026
  • #745

    Add an official HOL Guard pre-tool security example

    Updated Aug 23, 2026
  • #730

    Architecture: Preventing Context Drift in MCP Agents with Temporal Signatures

    Updated Aug 8, 2026
  • #673

    Agent identity for cross-org orchestration workflows

    Updated Jul 13, 2026
  • #718

    idea for rust wasm

    Updated Jul 13, 2026

> Tags

Pythonagentsaiai-agentsllm

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
CategoryAI 编程
PricingOpen source

> Related tools

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.