$git clone https://github.com/lastmile-ai/mcp-agent`mcp-agent` is a simple, composable framework to build effective agents using Model Context Protocol.
| 1 | <p align="center"> |
| 2 | <a href="https://docs.mcp-agent.com"><img src="https://github.com/user-attachments/assets/c8d059e5-bd56-4ea2-a72d-807fb4897bde" alt="Logo" width="300" /></a> |
| 3 | </p> |
| 4 | |
| 5 | <p align="center"> |
| 6 | <em>Build effective agents with Model Context Protocol using simple, composable patterns.</em> |
| 7 | |
| 8 | <p align="center"> |
| 9 | <a href="https://github.com/lastmile-ai/mcp-agent/tree/main/examples" target="_blank"><strong>Examples</strong></a> |
| 10 | | |
| 11 | <a href="https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/overview" target="_blank"><strong>Building Effective Agents</strong></a> |
| 12 | | |
| 13 | <a href="https://modelcontextprotocol.io/introduction" target="_blank"><strong>MCP</strong></a> |
| 14 | </p> |
| 15 | |
| 16 | <p align="center"> |
| 17 | <a href="https://docs.mcp-agent.com"><img src="https://img.shields.io/badge/docs-8F?style=flat&link=https%3A%2F%2Fdocs.mcp-agent.com%2F" /><a/> |
| 18 | <a href="https://pypi.org/project/mcp-agent/"><img src="https://img.shields.io/pypi/v/mcp-agent?color=%2334D058&label=pypi" /></a> |
| 19 | <img alt="Pepy Total Downloads" src="https://img.shields.io/pepy/dt/mcp-agent?label=pypi%20%7C%20downloads"/> |
| 20 | <a href="https://github.com/lastmile-ai/mcp-agent/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg"/></a> |
| 21 | <a href="https://lmai.link/discord/mcp-agent"><img src="https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord&logoColor=white" alt="discord"/></a> |
| 22 | </p> |
| 23 | |
| 24 | <p align="center"> |
| 25 | <a href="https://trendshift.io/repositories/13216" target="_blank"><img src="https://trendshift.io/api/badge/repositories/13216" alt="lastmile-ai%2Fmcp-agent | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a> |
| 26 | </p> |
| 27 | |
| 28 | ## Overview |
| 29 | |
| 30 | **`mcp-agent`** is a simple, composable framework to build effective agents using [Model Context Protocol](https://modelcontextprotocol.io/introduction). |
| 31 | |
| 32 | > [!Note] |
| 33 | > 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_. |
| 34 | |
| 35 | `mcp-agent` gives you the following: |
| 36 | |
| 37 | 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. |
| 38 | 2. **Effective agent patterns**: It implements every pattern described in Anthropic's [Building Effective Agents](https://www.anthropic.com/engineering/building-effective-agents) in a _composable_ way, allowing you to chain these patterns together. |
| 39 | 3. **Durable agents**: It works for simple agents and scales to sophisticated workflows built on [Temporal](https://temporal.io/) so you can pause, resume, and recover without any API changes to your agent. |
| 40 | |
| 41 | <u>Altogether, this is the simplest and easiest way to build robust agent applications</u>. |
| 42 | |
| 43 | We welcome all kinds of [contributions](/CONTRIBUTING.md), feedback and your help in improving this project. |
| 44 | |
| 45 | <a id="minimal-example"></a> |
| 46 | **Minimal example** |
| 47 | |
| 48 | ```python |
| 49 | import asyncio |
| 50 | |
| 51 | from mcp_agent.app import MCPApp |
| 52 | from mcp_agent.agents.agent import Agent |
| 53 | from mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM |
| 54 | |
| 55 | app = MCPApp(name="hello_world") |
| 56 | |
| 57 | async def main(): |
| 58 | async with app.run(): |
| 59 | agent = Agent( |
| 60 | name="finder", |
| 61 | instruction="Use filesystem and fetch to answer questions.", |
| 62 | server_names=["filesystem", "fetch"], |
| 63 | ) |
| 64 | async with agent: |
| 65 | llm = await agent.attach_llm(OpenAIAugmentedLLM) |
| 66 | answer = await llm.generate_str("Summarize README.md in two sentences.") |
| 67 | print(answer) |
| 68 | |
| 69 | |
| 70 | if __name__ == "__main__": |
| 71 | asyncio.run(main()) |
| 72 | |
| 73 | # Add your LLM API key to `mcp_agent.secrets.yaml` or set it in env. |
| 74 | # The [Getting Started guide](https://docs.mcp-agent.com/get-started/overview) walks through configuration and secrets in detail. |
| 75 | |
| 76 | ``` |
| 77 | |
| 78 | ## At a glance |
| 79 | |
| 80 | <table> |
| 81 | <tr> |
| 82 | <td width="50%" valign="top"> |
| 83 | <h3>Build an Agent</h3> |
| 84 | <p>Connect LLMs to MCP servers in simple, composable patterns like map-reduce, orc |