{"id":26571000,"url":"https://github.com/lastmile-ai/mcp-agent","last_synced_at":"2026-08-27T23:38:41.841Z","repository":{"id":272678843,"uuid":"905016458","full_name":"lastmile-ai/mcp-agent","owner":"lastmile-ai","description":"Build effective agents using Model Context Protocol and simple workflow patterns","archived":false,"fork":false,"pushed_at":"2026-01-25T16:35:16.000Z","size":27351,"stargazers_count":8491,"open_issues_count":135,"forks_count":871,"subscribers_count":48,"default_branch":"main","last_synced_at":"2026-08-06T03:33:10.297Z","etag":null,"topics":["agents","ai","ai-agents","llm","llms","mcp","model-context-protocol","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lastmile-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":"docs/roadmap.mdx","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"claude":null,"gemini":null,"cursor":null,"copilot":null,"dco":null,"cla":null,"disclosure":null}},"created_at":"2024-12-18T01:55:10.000Z","updated_at":"2026-08-05T21:25:12.000Z","dependencies_parsed_at":"2026-08-06T03:58:16.701Z","dependency_job_id":null,"html_url":"https://github.com/lastmile-ai/mcp-agent","commit_stats":null,"previous_names":["lastmile-ai/mcp-agent","saqadri/mcp-agent"],"tags_count":61,"template":false,"template_full_name":null,"purl":"pkg:github/lastmile-ai/mcp-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastmile-ai%2Fmcp-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastmile-ai%2Fmcp-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastmile-ai%2Fmcp-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastmile-ai%2Fmcp-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lastmile-ai","download_url":"https://codeload.github.com/lastmile-ai/mcp-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastmile-ai%2Fmcp-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36947769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-08-22T15:14:58.755Z","status":"online","status_checked_at":"2026-08-27T02:00:07.166Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","ai","ai-agents","llm","llms","mcp","model-context-protocol","python"],"created_at":"2025-03-22T22:19:28.117Z","updated_at":"2026-08-27T23:38:41.834Z","avatar_url":"https://github.com/lastmile-ai.png","language":"Python","funding_links":[],"categories":["Frameworks \u0026 SDKs","MCP Middleware \u0026 Orchestration","Foundation Models, LLMs, and Agents","Frameworks","📚 Projects (1974 total)","Python","Design Primitives","🤖 AI/ML","MCP 更多玩法","A01_文本生成_文本对话","HarmonyOS","Agent Development Frameworks","4. Agentic AI \u0026 Multi-Agent Systems","Repos","🧪 Demos \u0026 Projects","Tool / protocol / connector layer","Orchestration Frameworks","Table of Contents","AI Agent Frameworks \u0026 SDKs","🔌 ツールと API 連携","Tools","MCP Ecosystem","MCP Clients","AI Agents","MCP Servers \u0026 Protocol","🔎 Select Context","🤖 AI \u0026 Machine Learning","Catalog","Agentic AI ![](https://img.shields.io/badge/_-AGENTIC-22d3ee?style=flat-square\u0026logo=openai\u0026logoColor=white)","Agent frameworks"],"sub_categories":["Trading \u0026 Exchanges","Agent Protocols, Memory, and Tooling","Common Lisp","MCP Servers","Skills \u0026 MCP","🛠️ \u003ca name=\"other-tools-and-integrations\"\u003e\u003c/a\u003eOther Tools and Integrations","更多 MCP Server 资源","大语言对话模型及数据","Windows Manager","Frameworks","MCP Agents","AI Services","Orchestration Frameworks","その他の標準","Community","Core \u0026 Frameworks","Codex Resources","Tools","Agent Orchestration Platforms","Agent Frameworks and Runtimes","MCP Frameworks","Harness Architecture \u0026 Orchestration","Agentic frameworks"],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://docs.mcp-agent.com\"\u003e\u003cimg src=\"https://github.com/user-attachments/assets/c8d059e5-bd56-4ea2-a72d-807fb4897bde\" alt=\"Logo\" width=\"300\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cem\u003eBuild effective agents with Model Context Protocol using simple, composable patterns.\u003c/em\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/tree/main/examples\" target=\"_blank\"\u003e\u003cstrong\u003eExamples\u003c/strong\u003e\u003c/a\u003e\n  |\n  \u003ca href=\"https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/overview\" target=\"_blank\"\u003e\u003cstrong\u003eBuilding Effective Agents\u003c/strong\u003e\u003c/a\u003e\n  |\n  \u003ca href=\"https://modelcontextprotocol.io/introduction\" target=\"_blank\"\u003e\u003cstrong\u003eMCP\u003c/strong\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://docs.mcp-agent.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/docs-8F?style=flat\u0026link=https%3A%2F%2Fdocs.mcp-agent.com%2F\" /\u003e\u003ca/\u003e\n\u003ca href=\"https://pypi.org/project/mcp-agent/\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/mcp-agent?color=%2334D058\u0026label=pypi\" /\u003e\u003c/a\u003e\n\u003cimg alt=\"Pepy Total Downloads\" src=\"https://img.shields.io/pepy/dt/mcp-agent?label=pypi%20%7C%20downloads\"/\u003e\n\u003ca href=\"https://github.com/lastmile-ai/mcp-agent/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-Apache_2.0-blue.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://lmai.link/discord/mcp-agent\"\u003e\u003cimg src=\"https://img.shields.io/badge/Discord-%235865F2.svg?logo=discord\u0026logoColor=white\" alt=\"discord\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://trendshift.io/repositories/13216\" target=\"_blank\"\u003e\u003cimg src=\"https://trendshift.io/api/badge/repositories/13216\" alt=\"lastmile-ai%2Fmcp-agent | Trendshift\" style=\"width: 250px; height: 55px;\" width=\"250\" height=\"55\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\n**`mcp-agent`** is a simple, composable framework to build effective agents using [Model Context Protocol](https://modelcontextprotocol.io/introduction).\n\n\u003e [!Note]\n\u003e 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_.\n\n`mcp-agent` gives you the following:\n\n1. **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.\n2. **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.\n3. **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.\n\n\u003cu\u003eAltogether, this is the simplest and easiest way to build robust agent applications\u003c/u\u003e.\n\nWe welcome all kinds of [contributions](/CONTRIBUTING.md), feedback and your help in improving this project.\n\n\u003ca id=\"minimal-example\"\u003e\u003c/a\u003e\n**Minimal example**\n\n```python\nimport asyncio\n\nfrom mcp_agent.app import MCPApp\nfrom mcp_agent.agents.agent import Agent\nfrom mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM\n\napp = MCPApp(name=\"hello_world\")\n\nasync def main():\n    async with app.run():\n        agent = Agent(\n            name=\"finder\",\n            instruction=\"Use filesystem and fetch to answer questions.\",\n            server_names=[\"filesystem\", \"fetch\"],\n        )\n        async with agent:\n            llm = await agent.attach_llm(OpenAIAugmentedLLM)\n            answer = await llm.generate_str(\"Summarize README.md in two sentences.\")\n            print(answer)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n\n# Add your LLM API key to `mcp_agent.secrets.yaml` or set it in env.\n# The [Getting Started guide](https://docs.mcp-agent.com/get-started/overview) walks through configuration and secrets in detail.\n\n```\n\n## At a glance\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd width=\"50%\" valign=\"top\"\u003e\n      \u003ch3\u003eBuild an Agent\u003c/h3\u003e\n      \u003cp\u003eConnect LLMs to MCP servers in simple, composable patterns like map-reduce, orchestrator, evaluator-optimizer, router \u0026 more.\u003c/p\u003e\n      \u003cp\u003e\n        \u003ca href=\"https://docs.mcp-agent.com/get-started/overview\"\u003eQuick Start ↗\u003c/a\u003e | \n        \u003ca href=\"https://docs.mcp-agent.com/mcp-agent-sdk/overview\"\u003eDocs ↗\u003c/a\u003e\n      \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"50%\" valign=\"top\"\u003e\n      \u003ch3\u003eCreate any kind of MCP Server\u003c/h3\u003e\n      \u003cp\u003eCreate MCP servers with a FastMCP-compatible API. You can even expose agents as MCP servers.\u003c/p\u003e\n      \u003cp\u003e\n        \u003ca href=\"https://docs.mcp-agent.com/mcp-agent-sdk/mcp/agent-as-mcp-server\"\u003eMCP Agent Server ↗\u003c/a\u003e | \n        \u003ca href=\"https://docs.mcp-agent.com/cloud/use-cases/deploy-chatgpt-apps\"\u003e🎨 Build a ChatGPT App ↗\u003c/a\u003e | \n        \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/tree/main/examples/mcp_agent_server\"\u003eExamples ↗\u003c/a\u003e\n      \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n    \u003ctr\u003e\n    \u003ctd width=\"50%\" valign=\"top\"\u003e\n      \u003ch3\u003eFull MCP Support\u003c/h3\u003e\n      \u003cp\u003e\u003cb\u003eCore:\u003c/b\u003e Tools ✅ Resources ✅ Prompts ✅ Notifications ✅\u003cbr/\u003e\n      \u003cb\u003eAdvanced\u003c/b\u003e: OAuth ✅ Sampling ✅ Elicitation ✅ Roots ✅\u003c/p\u003e\n      \u003cp\u003e\n        \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/tree/main/examples/mcp\"\u003eExamples ↗\u003c/a\u003e | \n        \u003ca href=\"https://modelcontextprotocol.io/docs/getting-started/intro\"\u003eMCP Docs ↗\u003c/a\u003e\n      \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"50%\" valign=\"top\"\u003e\n      \u003ch3\u003eDurable Execution (Temporal)\u003c/h3\u003e\n      \u003cp\u003eScales to production workloads using Temporal as the agent runtime backend \u003ci\u003ewithout any API changes\u003c/i\u003e.\u003c/p\u003e\n      \u003cp\u003e\n        \u003ca href=\"https://docs.mcp-agent.com/mcp-agent-sdk/advanced/durable-agents\"\u003eDocs ↗\u003c/a\u003e | \n        \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/tree/main/examples/temporal\"\u003eExamples ↗\u003c/a\u003e\n      \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd width=\"50%\" valign=\"top\"\u003e\n      \u003ch3\u003e☁️ Deploy to Cloud\u003c/h3\u003e\n      \u003cp\u003e\u003cb\u003eBeta:\u003c/b\u003e Deploy agents yourself, or use \u003cb\u003emcp-c\u003c/b\u003e for a managed agent runtime. All apps are deployed as MCP servers.\u003c/p\u003e\n      \u003cp\u003e\n        \u003ca href=\"https://www.youtube.com/watch?v=0C4VY-3IVNU\"\u003eDemo ↗\u003c/a\u003e |\n        \u003ca href=\"https://docs.mcp-agent.com/get-started/cloud\"\u003eCloud Quickstart ↗\u003c/a\u003e | \n        \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/tree/main/examples/cloud\"\u003eExamples ↗\u003c/a\u003e\n      \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n## Documentation \u0026 build with LLMs\n\nmcp-agent's complete documentation is available at **[docs.mcp-agent.com](https://docs.mcp-agent.com)**, including full SDK guides, CLI reference, and advanced patterns. This readme gives a high-level overview to get you started.\n\n- [`llms-full.txt`](https://docs.mcp-agent.com/llms-full.txt): contains entire documentation.\n- [`llms.txt`](https://docs.mcp-agent.com/llms.txt): sitemap listing key pages in the docs.\n- [docs MCP server](https://docs.mcp-agent.com/mcp)\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Minimal example](#minimal-example)\n- [Quickstart](#get-started)\n- [Why mcp-agent](#why-use-mcp-agent)\n- [Core concepts](#core-components)\n  - [MCPApp](#mcpapp)\n  - [Agents \u0026 AgentSpec](#agents--agentspec)\n  - [Augmented LLM](#augmented-llm)\n  - [Workflows \u0026 decorators](#workflows--decorators)\n  - [Configuration \u0026 secrets](#configuration--secrets)\n  - [MCP integration](#mcp-integration)\n- [Workflow patterns](#workflow-patterns)\n- [CLI reference](#cli-reference)\n- [Authentication](#authentication)\n- [Advanced](#advanced)\n  - [Observability \u0026 controls](#observability--controls)\n  - [Composing workflows](#composing-workflows)\n  - [Durable execution](#durable-execution)\n  - [Agent servers](#agent-servers)\n  - [Signals \u0026 human input](#signals--human-input)\n  - [App configuration](#app-configuration)\n  - [Icons](#icons)\n  - [MCP server management](#mcp-server-management)\n- [Cloud deployment](#cloud-deployment)\n- [Examples](#examples)\n- [FAQs](#faqs)\n- [Community \u0026 contributions](#contributing)\n\n## Get Started\n\n\u003e [!TIP]\n\u003e The CLI is available via `uvx mcp-agent`.\n\u003e To get up and running,\n\u003e scaffold a project with `uvx mcp-agent init` and deploy with `uvx mcp-agent deploy my-agent`.\n\u003e\n\u003e You can get up and running in 2 minutes by running these commands:\n\u003e\n\u003e ```bash\n\u003e mkdir hello-mcp-agent \u0026\u0026 cd hello-mcp-agent\n\u003e uvx mcp-agent init\n\u003e uv init\n\u003e uv add \"mcp-agent[openai]\"\n\u003e # Add openai API key to `mcp_agent.secrets.yaml` or set `OPENAI_API_KEY`\n\u003e uv run main.py\n\u003e ```\n\n### Installation\n\nWe recommend using [uv](https://docs.astral.sh/uv/) to manage your Python projects (`uv init`).\n\n```bash\nuv add \"mcp-agent\"\n```\n\nAlternatively:\n\n```bash\npip install mcp-agent\n```\n\nAlso add optional packages for LLM providers (e.g. `uv add \"mcp-agent[openai, anthropic, google, azure, bedrock]\"`).\n\n### Quickstart\n\n\u003e [!TIP]\n\u003e The [`examples`](/examples) directory has several example applications to get started with.\n\u003e To run an example, clone this repo (or generate one with `uvx mcp-agent init --template basic --dir my-first-agent`)\n\u003e\n\u003e ```bash\n\u003e cd examples/basic/mcp_basic_agent # Or any other example\n\u003e # Option A: secrets YAML\n\u003e # cp mcp_agent.secrets.yaml.example mcp_agent.secrets.yaml \u0026\u0026 edit mcp_agent.secrets.yaml\n\u003e uv run main.py\n\u003e ```\n\nHere 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](./examples/basic/mcp_basic_agent/):\n\n\u003cdetails open\u003e\n\u003csummary\u003efinder_agent.py\u003c/summary\u003e\n\n```python\nimport asyncio\nimport os\n\nfrom mcp_agent.app import MCPApp\nfrom mcp_agent.agents.agent import Agent\nfrom mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM\n\napp = MCPApp(name=\"hello_world_agent\")\n\nasync def example_usage():\n    async with app.run() as mcp_agent_app:\n        logger = mcp_agent_app.logger\n        # This agent can read the filesystem or fetch URLs\n        finder_agent = Agent(\n            name=\"finder\",\n            instruction=\"\"\"You can read local files or fetch URLs.\n                Return the requested information when asked.\"\"\",\n            server_names=[\"fetch\", \"filesystem\"], # MCP servers this Agent can use\n        )\n\n        async with finder_agent:\n            # Automatically initializes the MCP servers and adds their tools for LLM use\n            tools = await finder_agent.list_tools()\n            logger.info(f\"Tools available:\", data=tools)\n\n            # Attach an OpenAI LLM to the agent (defaults to GPT-4o)\n            llm = await finder_agent.attach_llm(OpenAIAugmentedLLM)\n\n            # This will perform a file lookup and read using the filesystem server\n            result = await llm.generate_str(\n                message=\"Show me what's in README.md verbatim\"\n            )\n            logger.info(f\"README.md contents: {result}\")\n\n            # Uses the fetch server to fetch the content from URL\n            result = await llm.generate_str(\n                message=\"Print the first two paragraphs from https://www.anthropic.com/research/building-effective-agents\"\n            )\n            logger.info(f\"Blog intro: {result}\")\n\n            # Multi-turn interactions by default\n            result = await llm.generate_str(\"Summarize that in a 128-char tweet\")\n            logger.info(f\"Tweet: {result}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(example_usage())\n\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003emcp_agent.config.yaml\u003c/summary\u003e\n\n```yaml\nexecution_engine: asyncio\nlogger:\n  transports: [console] # You can use [file, console] for both\n  level: debug\n  path: \"logs/mcp-agent.jsonl\" # Used for file transport\n  # For dynamic log filenames:\n  # path_settings:\n  #   path_pattern: \"logs/mcp-agent-{unique_id}.jsonl\"\n  #   unique_id: \"timestamp\"  # Or \"session_id\"\n  #   timestamp_format: \"%Y%m%d_%H%M%S\"\n\nmcp:\n  servers:\n    fetch:\n      command: \"uvx\"\n      args: [\"mcp-server-fetch\"]\n    filesystem:\n      command: \"npx\"\n      args:\n        [\n          \"-y\",\n          \"@modelcontextprotocol/server-filesystem\",\n          \"\u003cadd_your_directories\u003e\",\n        ]\n\nopenai:\n  # Secrets (API keys, etc.) are stored in an mcp_agent.secrets.yaml file which can be gitignored\n  default_model: gpt-4o\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAgent output\u003c/summary\u003e\n\u003cimg width=\"2398\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/eaa60fdf-bcc6-460b-926e-6fa8534e9089\" /\u003e\n\u003c/details\u003e\n\n## Why use `mcp-agent`?\n\nThere are too many AI frameworks out there already. But `mcp-agent` is the only one that is purpose-built for a shared protocol - [MCP](https://modelcontextprotocol.io/introduction).[mcp-agent](https://docs.mcp-agent.com/get-started/welcome) 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:\n\n- **Composable** – every pattern ships as a reusable workflow you can mix and match.\n- **MCP-native** – any MCP server (filesystem, fetch, Slack, Jira, FastMCP apps) connects without custom adapters.\n- **Production ready** – Temporal-backed durability, structured logging, token accounting, and Cloud deploys are first-class.\n- **Pythonic** – a handful of decorators and context managers wire everything together.\n\nDocs: [Welcome to mcp-agent](https://docs.mcp-agent.com/get-started/welcome) • [Effective patterns overview](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/overview).\n\n## Core Components\n\nEvery project revolves around a single `MCPApp` runtime that loads configuration, registers agents and MCP servers, and exposes tools/workflows. The [Core Components guide](https://docs.mcp-agent.com/mcp-agent-sdk/overview) walks through these building blocks.\n\n### MCPApp\n\nInitialises configuration, logging, tracing, and the execution engine so everything shares one context.\n\n```python\nfrom mcp_agent.app import MCPApp\n\napp = MCPApp(name=\"finder_app\")\n\nasync def main():\n    async with app.run() as running_app:\n        logger = running_app.logger\n        logger.info(\"App ready\", data={\"servers\": list(running_app.context.server_registry.registry)})\n```\n\nDocs: [MCPApp](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/mcpapp) • Example: [`examples/basic/mcp_basic_agent`](./examples/basic/mcp_basic_agent/).\n\n### Agents \u0026 AgentSpec\n\nAgents 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.\n\n```python\nfrom pathlib import Path\nfrom mcp_agent.agents.agent import Agent\nfrom mcp_agent.workflows.factory import load_agent_specs_from_file\n\nagent = Agent(\n    name=\"researcher\",\n    instruction=\"Research topics using web and filesystem access\",\n    server_names=[\"fetch\", \"filesystem\"],\n)\n\nasync with agent:\n    tools = await agent.list_tools()\n\nasync with app.run() as running_app:\n    specs = load_agent_specs_from_file(\n        str(Path(\"examples/basic/agent_factory/agents.yaml\")),\n        context=running_app.context,\n    )\n```\n\nDocs: [Agents](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/agents) • [Agent factory helpers](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/agents#agentspec-and-factory-helpers) • Examples: [`examples/basic/agent_factory`](./examples/basic/agent_factory/).\n\n### Augmented LLM\n\nAugmented 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`.\n\n```python\nfrom pydantic import BaseModel\nfrom mcp_agent.workflows.llm.augmented_llm import RequestParams\nfrom mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM\n\nclass Summary(BaseModel):\n    title: str\n    verdict: str\n\nasync with agent:\n    llm = await agent.attach_llm(OpenAIAugmentedLLM)\n    report = await llm.generate_str(\n        message=\"Draft a 3-sentence release note from CHANGELOG.md\",\n        request_params=RequestParams(maxTokens=400, temperature=0.2),\n    )\n    structured = await llm.generate_structured(\n        message=\"Return a JSON object with `title` and `verdict` summarising the README.\",\n        response_model=Summary,\n    )\n```\n\nDocs: [Augmented LLMs](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/augmented-llm) • Examples: [`examples/basic/mcp_basic_agent`](./examples/basic/mcp_basic_agent/) and the workflow projects listed in [gallery.md](gallery.md#workflow-patterns).\n\n### Workflows \u0026 decorators\n\n`MCPApp` decorators convert coroutines into durable workflows and tools. The same annotations work for both `asyncio` and Temporal execution.\n\n```python\nfrom datetime import timedelta\nfrom mcp_agent.executor.workflow import Workflow, WorkflowResult\n\n@app.workflow\nclass PublishArticle(Workflow[WorkflowResult[str]]):\n    @app.workflow_task(schedule_to_close_timeout=timedelta(minutes=5))\n    async def draft(self, topic: str) -\u003e str:\n        return f\"- intro to {topic}\\n- highlights\\n- next steps\"\n\n    @app.workflow_run\n    async def run(self, topic: str) -\u003e WorkflowResult[str]:\n        outline = await self.draft(topic)\n        return WorkflowResult(value=outline)\n```\n\nDocs: [Decorator reference](https://docs.mcp-agent.com/reference/decorators) • Examples: [`examples/workflows`](./examples/workflows/).\n\n### Configuration \u0026 secrets\n\nSettings load from `mcp_agent.config.yaml`, `mcp_agent.secrets.yaml`, environment variables, and optional preload strings. Keep secrets out of source control.\n\n```yaml\n# mcp_agent.config.yaml\nexecution_engine: asyncio\nmcp:\n  servers:\n    fetch:\n      command: \"uvx\"\n      args: [\"mcp-server-fetch\"]\n    filesystem:\n      command: \"npx\"\n      args: [\"-y\", \"@modelcontextprotocol/server-filesystem\"]\nopenai:\n  default_model: gpt-4o-mini\n\n# mcp_agent.secrets.yaml (gitignored)\nopenai:\n  api_key: \"${OPENAI_API_KEY}\"\n```\n\nDocs: [Configuration reference](https://docs.mcp-agent.com/reference/configuration) • [Specify secrets](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/specify-secrets).\n\n### MCP integration\n\nConnect to existing MCP servers programmatically or aggregate several into one façade.\n\n```python\nfrom mcp_agent.mcp.gen_client import gen_client\n\nasync with app.run():\n    async with gen_client(\"filesystem\", app.server_registry, context=app.context) as client:\n        resources = await client.list_resources()\n        app.logger.info(\"Filesystem resources\", data={\"uris\": [r.uri for r in resources.resources]})\n```\n\nDocs: [MCP integration overview](https://docs.mcp-agent.com/mcp/overview) • Examples: [`examples/mcp`](./examples/mcp/).\n\n## Workflow patterns\n\nKey agent patterns are implemented as an `AugmentedLLM`. Use factory helpers to wire them up or inspect the runnable projects listed in [gallery.md](gallery.md#workflow-patterns).\n\n| Pattern               | Helper                                                                          | Summary                                                                                                                                                                                                                                                                                                                                                                                                                                                            | Docs                                                                                                   |\n| --------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |\n| Parallel (Map-Reduce) | `create_parallel_llm(...)`                                                      | Fan-out specialists and fan-in aggregated reports.\u003cbr\u003e\u003ca href=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F406bb032ca007fd1624f261af717d70e6ca86286-2401x1000.png\u0026w=3840\u0026q=75\"\u003e\u003cimg src=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F406bb032ca007fd1624f261af717d70e6ca86286-2401x1000.png\u0026w=3840\u0026q=75\" width=\"260\"/\u003e\u003c/a\u003e     | [Parallel](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/map-reduce)                     |\n| Router                | `create_router_llm(...)` / `create_router_embedding(...)`                       | Route requests to the best agent, server, or function.\u003cbr\u003e\u003ca href=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F5c0c0e9fe4def0b584c04d37849941da55e5e71c-2401x1000.png\u0026w=3840\u0026q=75\"\u003e\u003cimg src=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F5c0c0e9fe4def0b584c04d37849941da55e5e71c-2401x1000.png\u0026w=3840\u0026q=75\" width=\"260\"/\u003e\u003c/a\u003e | [Router](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/router)                           |\n| Intent classifier     | `create_intent_classifier_llm(...)` / `create_intent_classifier_embedding(...)` | Bucket user input into intents before automation.                                                                                                                                                                                                                                                                                                                                                                                                                  | [Intent classifier](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/intent-classifier)     |\n| Orchestrator-workers  | `create_orchestrator(...)`                                                      | Generate plans and coordinate worker agents.\u003cbr\u003e\u003ca href=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F8985fc683fae4780fb34eab1365ab78c7e51bc8e-2401x1000.png\u0026w=3840\u0026q=75\"\u003e\u003cimg src=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F8985fc683fae4780fb34eab1365ab78c7e51bc8e-2401x1000.png\u0026w=3840\u0026q=75\" width=\"260\"/\u003e\u003c/a\u003e           | [Planner](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/planner)                         |\n| Deep research         | `create_deep_orchestrator(...)`                                                 | Long-horizon research with knowledge extraction and policy checks.                                                                                                                                                                                                                                                                                                                                                                                                 | [Deep research](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/deep-research)             |\n| Evaluator-optimizer   | `create_evaluator_optimizer_llm(...)`                                           | Iterate until an evaluator approves the result.\u003cbr\u003e\u003ca href=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F14f51e6406ccb29e695da48b17017e899a6119c7-2401x1000.png\u0026w=3840\u0026q=75\"\u003e\u003cimg src=\"https://www.anthropic.com/_next/image?url=https%3A%2F%2Fwww-cdn.anthropic.com%2Fimages%2F4zrzovbb%2Fwebsite%2F14f51e6406ccb29e695da48b17017e899a6119c7-2401x1000.png\u0026w=3840\u0026q=75\" width=\"260\"/\u003e\u003c/a\u003e        | [Evaluator-optimizer](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/evaluator-optimizer) |\n| Swarm                 | `create_swarm(...)`                                                             | Multi-agent handoffs compatible with OpenAI Swarm.\u003cbr\u003e\u003ca href=\"https://github.com/openai/swarm/blob/main/assets/swarm_diagram.png?raw=true\"\u003e\u003cimg src=\"https://github.com/openai/swarm/blob/main/assets/swarm_diagram.png?raw=true\" width=\"220\"/\u003e\u003c/a\u003e                                                                                                                                                                                                               | [Swarm](https://docs.mcp-agent.com/mcp-agent-sdk/effective-patterns/swarm)                             |\n\n## Durable execution\n\nSwitch `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.\n\n```python\nfrom mcp_agent.executor.temporal import create_temporal_worker_for_app\n\nasync with create_temporal_worker_for_app(app) as worker:\n    await worker.run()\n```\n\nDocs: [Durable agents](https://docs.mcp-agent.com/mcp-agent-sdk/advanced/durable-agents) • [Temporal backend](https://docs.mcp-agent.com/advanced/temporal) • Examples: [`examples/temporal`](./examples/temporal/).\n\n## Agent servers\n\nExpose an `MCPApp` as a standard MCP server so Claude Desktop, Cursor, or custom clients can call your tools and workflows.\n\n```python\nfrom mcp_agent.server import create_mcp_server_for_app\n\n@app.tool\ndef grade_story(story: str) -\u003e str:\n    return \"Report...\"\n\nif __name__ == \"__main__\":\n    server = create_mcp_server_for_app(app)\n    server.run_stdio()\n```\n\nDocs: [Agent servers](https://docs.mcp-agent.com/mcp-agent-sdk/mcp/agent-as-mcp-server) • Examples: [`examples/mcp_agent_server`](./examples/mcp_agent_server/).\n\n## CLI reference\n\n`uvx mcp-agent` scaffolds projects, manages secrets, inspects workflows, and deploys to Cloud.\n\n```bash\nuvx mcp-agent init --template basic             # Scaffold a new project\nuvx mcp-agent deploy my-agent                   # Deploy to mcp-agent Cloud\n```\n\nDocs: [CLI reference](https://docs.mcp-agent.com/reference/cli) • [Getting started guides](https://docs.mcp-agent.com/get-started/quickstart).\n\n## Authentication\n\nLoad API keys from secrets files or use the built-in OAuth client to fetch and persist tokens for MCP servers.\n\n```yaml\n# mcp_agent.config.yaml excerpt\noauth:\n  providers:\n    github:\n      client_id: \"${GITHUB_CLIENT_ID}\"\n      client_secret: \"${GITHUB_CLIENT_SECRET}\"\n      scopes: [\"repo\", \"user\"]\n```\n\nDocs: [Advanced authentication](https://docs.mcp-agent.com/mcp-agent-sdk/advanced/authentication) • [Server authentication](https://docs.mcp-agent.com/mcp-agent-sdk/mcp/server-authentication) • Examples: [`examples/basic/oauth_basic_agent`](./examples/basic/oauth_basic_agent/).\n\n## Advanced\n\n### Observability \u0026 controls\n\nEnable structured logging and OpenTelemetry via configuration, and track token usage programmatically.\n\n```yaml\n# mcp_agent.config.yaml\nlogger:\n  transports: [console]\n  level: info\notel:\n  enabled: true\n  exporters:\n    - console\n```\n\n`TokenCounter` tracks token usage for agents, workflows, and LLM nodes. Attach watchers to stream updates or trigger alerts.\n\n```python\n# Inside `async with app.run() as running_app:`\n# token_counter lives on the running app context when tracing is enabled.\ntoken_counter = running_app.context.token_counter\n\nclass TokenMonitor:\n    async def on_token_update(self, node, usage):\n        print(f\"[{node.name}] total={usage.total_tokens}\")\n\nmonitor = TokenMonitor()\nwatch_id = await token_counter.watch(\n    callback=monitor.on_token_update,\n    node_type=\"llm\",\n    threshold=1_000,\n    include_subtree=True,\n)\n\nawait token_counter.unwatch(watch_id)\n```\n\nDocs: [Observability](https://docs.mcp-agent.com/mcp-agent-sdk/advanced/observability) • Examples: [`examples/tracing`](./examples/tracing/).\n\n### Composing workflows\n\nMix and match AgentSpecs to build higher-level workflows using the factory helpers—routers, parallel pipelines, orchestrators, and more.\n\n```python\nfrom mcp_agent.workflows.factory import create_router_llm\n\n# specs are loaded via load_agent_specs_from_file as shown above.\nasync with app.run() as running_app:\n    router = await create_router_llm(\n        agents=specs,\n        provider=\"openai\",\n        context=running_app.context,\n    )\n```\n\nDocs: [Workflow composition](https://docs.mcp-agent.com/mcp-agent-sdk/advanced/composition) • Examples: [`examples/basic/agent_factory`](./examples/basic/agent_factory/).\n\n### Signals \u0026 human input\n\nPause workflows for approvals or extra data. Temporal stores state durably until an operator resumes the run.\n\n```python\nfrom mcp_agent.human_input.types import HumanInputRequest\n\nresponse = await self.context.request_human_input(\n    HumanInputRequest(\n        prompt=\"Approve the draft?\",\n        required=True,\n        metadata={\"workflow_id\": self.context.workflow_id},\n    )\n)\n```\n\nResume with `mcp-agent cloud workflows resume … --payload '{\"content\": \"approve\"}'`. Docs: [Deploy agents – human input](https://docs.mcp-agent.com/cloud/use-cases/deploy-agents#human-in-the-loop-patterns) • Examples: [`examples/human_input/temporal`](./examples/human_input/temporal/).\n\n### App configuration\n\nBuild `Settings` objects programmatically when you need dynamic config (tests, multi-tenant hosts) instead of YAML files.\n\n```python\nfrom mcp_agent.config import Settings, MCPSettings, MCPServerSettings\n\nsettings = Settings(\n    execution_engine=\"asyncio\",\n    mcp=MCPSettings(\n        servers={\n            \"fetch\": MCPServerSettings(command=\"uvx\", args=[\"mcp-server-fetch\"]),\n        }\n    ),\n)\napp = MCPApp(name=\"configured_app\", settings=settings)\n```\n\nDocs: [Configuring your application](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/configuring-your-application).\n\n### Icons\n\nAdd icons to agents and tools so MCP clients that support imagery (Claude Desktop, Cursor) render richer UIs.\n\n```python\nfrom base64 import standard_b64encode\nfrom pathlib import Path\nfrom mcp_agent.icons import Icon\n\nicon_data = standard_b64encode(Path(\"my-icon.png\").read_bytes()).decode()\nicon = Icon(src=f\"data:image/png;base64,{icon_data}\", mimeType=\"image/png\", sizes=[\"64x64\"])\n\napp = MCPApp(name=\"my_app_with_icon\", icons=[icon])\n\n@app.tool(icons=[icon])\nasync def my_tool() -\u003e str:\n    return \"Hello with style\"\n```\n\nDocs: [`MCPApp` icons](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/mcpapp#icons) • Examples: [`examples/mcp_agent_server/asyncio`](./examples/mcp_agent_server/asyncio/).\n\n### MCP server management\n\nUse `MCPAggregator` or `gen_client` to manage MCP server connections and expose combined tool sets.\n\n```python\nfrom mcp_agent.mcp.mcp_aggregator import MCPAggregator\n\nasync with MCPAggregator.create(server_names=[\"fetch\", \"filesystem\"]) as aggregator:\n    tools = await aggregator.list_tools()\n```\n\nDocs: [Connecting to MCP servers](https://docs.mcp-agent.com/mcp-agent-sdk/core-components/connecting-to-mcp-servers) • Examples: [`examples/basic/mcp_server_aggregator`](./examples/basic/mcp_server_aggregator/).\n\n## Cloud deployment\n\nDeploy to mcp-agent Cloud for managed Temporal execution, secrets, and HTTPS MCP endpoints.\n\n```bash\nuvx mcp-agent login\nuvx mcp-agent deploy my-agent\nuvx mcp-agent cloud apps list\n```\n\nDocs: [Cloud overview](https://docs.mcp-agent.com/cloud/overview) • [Deployment quickstart](https://docs.mcp-agent.com/cloud/deployment-quickstart) • Examples: [`examples/cloud`](./examples/cloud/).\n\n## Examples\n\nBrowse [gallery.md](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.\n\n## FAQs\n\n### What are the core benefits of using mcp-agent?\n\nmcp-agent provides a streamlined approach to building AI agents using capabilities exposed by **MCP** (Model Context Protocol) servers.\n\nMCP 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.\n\nCore benefits:\n\n- 🤝 **Interoperability**: ensures that any tool exposed by any number of MCP servers can seamlessly plug in to your agents.\n- ⛓️ **Composability \u0026 Customizability**: Implements well-defined workflows, but in a composable way that enables compound workflows, and allows full customization across model provider, logging, orchestrator, etc.\n- 💻 **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.\n- 🖐️ **Human Input \u0026 Signals**: Supports pausing workflows for external signals, such as human input, which are exposed as tool calls an Agent can make.\n\n### Do you need an MCP client to use mcp-agent?\n\nNo, 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.\n\nHere's all the ways you can set up your mcp-agent application:\n\n#### MCP-Agent Server\n\nYou can expose mcp-agent applications as MCP servers themselves (see [example](./examples/mcp_agent_server)), allowing MCP clients to interface with sophisticated AI workflows using the standard tools API of MCP servers. This is effectively a server-of-servers.\n\n#### MCP Client or Host\n\nYou can embed mcp-agent in an MCP client directly to manage the orchestration across multiple MCP servers.\n\n#### Standalone\n\nYou can use mcp-agent applications in a standalone fashion (i.e. they aren't part of an MCP client). The [`examples`](/examples/) are all standalone applications.\n\n### How do I deploy to Cloud?\n\nRun `uvx mcp-agent deploy \u003capp-name\u003e` 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/\ncloud) for step-by-step screenshots and CLI output.\n\n### Where is the API reference?\n\nEvery class, decorator, and CLI command is documented on [docs.mcp-agent.com](https://docs.mcp-agent.com). The [API reference](https://docs.mcp-agent.com/reference) and the [`llms-full.txt`](https://docs.mcp-agent.com/llms-full.txt) are designed so LLMs (or you) can ingest the whole surface area easily.\n\n### Tell me a fun fact\n\nI 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.\n\n## Contributing\n\nWe welcome contributions of every size—bug fixes, new examples, docs, or feature requests. Start with [CONTRIBUTING.md](./CONTRIBUTING.md), open a discussion, or drop by [Discord](https://lmai.link/discord/mcp-agent).\n\nmcp-agent would not be possible without the tireless efforts of the many open source contributors. Thank you!\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/lastmile-ai/mcp-agent/graphs/contributors\"\u003e\n    \u003cimg src=\"https://contrib.rocks/image?repo=lastmile-ai/mcp-agent\" alt=\"Contributor faces\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flastmile-ai%2Fmcp-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flastmile-ai%2Fmcp-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flastmile-ai%2Fmcp-agent/lists"}