Build effective agents with Model Context Protocol using simple, composable patterns.
Examples | Building Effective Agents | MCP
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:
- 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.
- 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.
- 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.
|
Connect LLMs to MCP servers in simple, composable patterns like map-reduce, orchestrator, evaluator-optimizer, router & more. |
Create MCP servers with a FastMCP-compatible API. You can even expose agents as MCP servers. |
|
Core: Tools ✅ Resources ✅ Prompts ✅ Notifications ✅ |
Scales to production workloads using Temporal as the agent runtime backend without any API changes. |
|
Beta: Deploy agents yourself, or use mcp-c for a managed agent runtime. All apps are deployed as MCP servers. |
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
- Overview
- Minimal example
- Quickstart
- Why mcp-agent
- Core concepts
- Workflow patterns
- CLI reference
- Authentication
- Advanced
- Cloud deployment
- Examples
- FAQs
- Community & contributions
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:
We recommend using uv to manage your Python projects (uv init).
Alternatively:
Also add optional packages for LLM providers (e.g. uv add "mcp-agent[openai, anthropic, google, azure, bedrock]").
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)
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
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.
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.
Initialises configuration, logging, tracing, and the execution engine so everything shares one context.
Docs: MCPApp • Example: examples/basic/mcp_basic_agent.
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.
Docs: Agents • Agent factory helpers • Examples: examples/basic/agent_factory.
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.
MCPApp decorators convert coroutines into durable workflows and tools. The same annotations work for both asyncio and Temporal execution.
Docs: Decorator reference • Examples: examples/workflows.
Settings load from mcp_agent.config.yaml, mcp_agent.secrets.yaml, environment variables, and optional preload strings. Keep secrets out of source control.
Docs: Configuration reference • Specify secrets.
Connect to existing MCP servers programmatically or aggregate several into one façade.
Docs: MCP integration overview • Examples: examples/mcp.
Key agent patterns are implemented as an AugmentedLLM. Use factory helpers to wire them up or inspect the runnable projects listed in gallery.md.
Switch execution_engine to temporal for pause/resume, retries, human input, and durable history—without changing workflow code. Run a worker alongside your app to host activities.
Docs: Durable agents • Temporal backend • Examples: examples/temporal.
Expose an MCPApp as a standard MCP server so Claude Desktop, Cursor, or custom clients can call your tools and workflows.
Docs: Agent servers • Examples: examples/mcp_agent_server.
uvx mcp-agent scaffolds projects, manages secrets, inspects workflows, and deploys to Cloud.
Docs: CLI reference • Getting started guides.
Load API keys from secrets files or use the built-in OAuth client to fetch and persist tokens for MCP servers.
Docs: Advanced authentication • Server authentication • Examples: examples/basic/oauth_basic_agent.
Enable structured logging and OpenTelemetry via configuration, and track token usage programmatically.
TokenCounter tracks token usage for agents, workflows, and LLM nodes. Attach watchers to stream updates or trigger alerts.
Docs: Observability • Examples: examples/tracing.
Mix and match AgentSpecs to build higher-level workflows using the factory helpers—routers, parallel pipelines, orchestrators, and more.
Docs: Workflow composition • Examples: examples/basic/agent_factory.
Pause workflows for approvals or extra data. Temporal stores state durably until an operator resumes the run.
Resume with mcp-agent cloud workflows resume … --payload '{"content": "approve"}'. Docs: Deploy agents – human input • Examples: examples/human_input/temporal.
Build Settings objects programmatically when you need dynamic config (tests, multi-tenant hosts) instead of YAML files.
Docs: Configuring your application.
Add icons to agents and tools so MCP clients that support imagery (Claude Desktop, Cursor) render richer UIs.
Docs: MCPApp icons • Examples: examples/mcp_agent_server/asyncio.
Use MCPAggregator or gen_client to manage MCP server connections and expose combined tool sets.
Docs: Connecting to MCP servers • Examples: examples/basic/mcp_server_aggregator.
Deploy to mcp-agent Cloud for managed Temporal execution, secrets, and HTTPS MCP endpoints.
Docs: Cloud overview • Deployment quickstart • Examples: examples/cloud.
Browse gallery.md for runnable examples, demo videos, and community projects grouped by concept. Every entry cites the docs page and command you need to run it locally.
mcp-agent provides a streamlined approach to building AI agents using capabilities exposed by MCP (Model Context Protocol) servers.
MCP is quite low-level, and this framework handles the mechanics of connecting to servers, working with LLMs, handling external signals (like human input) and supporting persistent state via durable execution. That lets you, the developer, focus on the core business logic of your AI application.
Core benefits:
- 🤝 Interoperability: ensures that any tool exposed by any number of MCP servers can seamlessly plug in to your agents.
- ⛓️ Composability & Customizability: Implements well-defined workflows, but in a composable way that enables compound workflows, and allows full customization across model provider, logging, orchestrator, etc.
- 💻 Programmatic control flow: Keeps things simple as developers just write code instead of thinking in graphs, nodes and edges. For branching logic, you write if statements. For cycles, use while loops.
- 🖐️ Human Input & Signals: Supports pausing workflows for external signals, such as human input, which are exposed as tool calls an Agent can make.
No, you can use mcp-agent anywhere, since it handles MCPClient creation for you. This allows you to leverage MCP servers outside of MCP hosts like Claude Desktop.
Here's all the ways you can set up your mcp-agent application:
You can expose mcp-agent applications as MCP servers themselves (see example), allowing MCP clients to interface with sophisticated AI workflows using the standard tools API of MCP servers. This is effectively a server-of-servers.
You can embed mcp-agent in an MCP client directly to manage the orchestration across multiple MCP servers.
You can use mcp-agent applications in a standalone fashion (i.e. they aren't part of an MCP client). The examples are all standalone applications.
Run uvx mcp-agent deploy <app-name> after logging in with uvx mcp-agent login. The CLI packages your project, provisions secrets, and exposes an MCP endpoint backed by a durable Temporal runtime. See the [Cloud quickstart](https://docs.mcp-agent.com/get-started/ cloud) for step-by-step screenshots and CLI output.
Every class, decorator, and CLI command is documented on docs.mcp-agent.com. The API reference and the llms-full.txt are designed so LLMs (or you) can ingest the whole surface area easily.
I debated naming this project silsila (سلسلہ), which means chain of events in Urdu. mcp-agent is more matter-of-fact, but there's still an easter egg in the project paying homage to silsila.
We welcome contributions of every size—bug fixes, new examples, docs, or feature requests. Start with CONTRIBUTING.md, open a discussion, or drop by Discord.
mcp-agent would not be possible without the tireless efforts of the many open source contributors. Thank you!
.png)

