{
 "kind": "tool",
 "slug": "mcp",
 "path": "tools/mcp/",
 "name": "Model Context Protocol SDK (Python)",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Agent, MCP and tool libraries",
   "tools/agent-libraries/"
  ]
 ],
 "lead": "Python SDK for building MCP servers and clients to extend AI agent capabilities.",
 "chips": [
  {
   "label": "Agent, MCP and tool libraries",
   "path": "tools/agent-libraries/"
  },
  {
   "label": "PYPI"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "pip install mcp"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/modelcontextprotocol/python-sdk"
  },
  {
   "label": "Website",
   "href": "https://modelcontextprotocol.io"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from PyPI classifier.",
   "src": "https://github.com/modelcontextprotocol/python-sdk"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change today",
   "note": "Latest GitHub release Oct 2, 2026. ",
   "src": "https://github.com/modelcontextprotocol/python-sdk"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "499 projects",
   "status": "info",
   "sub": "#2 of 192 in its category",
   "note": "Dependency in 499 public GitHub projects set up for AI coding agents that we scanned (8.0%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "yes",
   "sub": "llms.txt",
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": "https://py.sdk.modelcontextprotocol.io/llms.txt"
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Model Context Protocol SDK (Python) does",
   "parts": [
    {
     "t": "prose",
     "text": "One official package covers both sides of MCP in Python: you write servers as plain type-hinted functions, and the same install gives you a client. The current v2 line renames and removes enough v1 API that older tutorials no longer run as written."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Model Context Protocol SDK (Python) popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "83",
       "of": "/ 100",
       "l": "Gid Score, #59 overall"
      },
      {
       "n": "82M",
       "l": "downloads a week, pypi"
      },
      {
       "n": "24.9K",
       "l": "GitHub stars"
      },
      {
       "n": "499",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Model Context Protocol SDK (Python) is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Model Context Protocol SDK (Python) is a dependency in 499 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (30.7% of the 1,623 Python ones), #2 of 192 in agent, mcp and tool libraries.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 1,392; those are left out of every share on this page.",
      "The most used alternative in our scan is Pydantic AI (16 projects).",
      "Projects that use it most often also use Pydantic (36.5%), python-dotenv (33.7%), Uvicorn (28.7%).",
      "It is more common in projects set up for Claude Code (8.2%) than for OpenAI Codex (2.8%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "269 projects, 8.2%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "221 projects, 7.3%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "183 projects, 7.5%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "17 projects, 5.0%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "16 projects, 3.4%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "15 projects, 4.5%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "13 projects, 2.8%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "9 projects, 3.2%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 36.5% of its projects",
       "v": "Pydantic",
       "path": "tools/pydantic/"
      },
      {
       "l": "In 33.7% of its projects",
       "v": "python-dotenv",
       "path": "tools/python-dotenv/"
      },
      {
       "l": "In 28.7% of its projects",
       "v": "Uvicorn",
       "path": "tools/uvicorn/"
      },
      {
       "l": "In 24.6% of its projects",
       "v": "httpx",
       "path": "tools/httpx/"
      },
      {
       "l": "In 25.1% of its projects",
       "v": "FastAPI",
       "path": "tools/fastapi/"
      },
      {
       "l": "In 20.4% of its projects",
       "v": "Requests",
       "path": "tools/requests-py/"
      },
      {
       "l": "In 15.6% of its projects",
       "v": "OpenAI Python Library",
       "path": "tools/openai-pypi/"
      },
      {
       "l": "In 15.0% of its projects",
       "v": "Pydantic Settings",
       "path": "tools/pydantic-settings/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "Model Context Protocol SDK (Python) in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Type hints become the tool schema",
       "v": "The docs' first example is two decorated functions. It needs no hand-written JSON Schema, request parsing or validation code. In the docs' words, <code>a: int, b: int</code> is the schema."
      },
      {
       "l": "Hosts build input forms from your signatures",
       "v": "The docs say the MCP Inspector builds a form with required integer fields straight from the function's type hints. They say Claude and other MCP hosts do the same."
      },
      {
       "l": "Server and client in one install",
       "v": "The same package that serves tools also has a <code>Client</code>. The README shows it in about 10 lines. Given a URL, <code>Client</code> uses Streamable HTTP. It can also launch a local server as a stdio subprocess or take a custom transport."
      },
      {
       "l": "Mounts inside an existing FastAPI or Starlette app",
       "v": "You do not need a separate service. The docs have a page on mounting an MCP server inside a FastAPI or Starlette app you already run."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "v2 breaks v1 imports, starting with FastMCP",
       "v": "In v2, <code>FastMCP</code> is now <code>MCPServer</code>. Code that imports <code>mcp.server.fastmcp</code> fails on import. The migration guide lists more renames: camelCase fields became snake_case, and <code>McpError</code> became <code>MCPError</code>."
      },
      {
       "l": "Pin below 2 if you have not migrated",
       "v": "The maintainers advise packages that depend on <code>mcp</code> to keep a <code>&lt;2</code> upper bound until they move to v2. v1.x still gets critical bug fixes and security patches."
      },
      {
       "l": "httpx is gone from the dependency tree",
       "v": "v2 depends on <code>httpx2</code> instead of <code>httpx</code> and <code>httpx-sse</code>. If your own code imported <code>httpx</code> only because v1 installed it, that import now fails. The traceback never mentions mcp."
      }
     ]
    },
    {
     "t": "h3",
     "text": "A complete MCP server: one tool, one templated resource"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Python",
       "code": "from mcp.server import MCPServer\n\nmcp = MCPServer(\"Demo\")\n\n\n@mcp.tool()\ndef add(a: int, b: int) -> int:\n    \"\"\"Add two numbers.\"\"\"\n    return a + b\n\n\n@mcp.resource(\"greeting://{name}\")\ndef greeting(name: str) -> str:\n    \"\"\"Greet someone by name.\"\"\"\n    return f\"Hello, {name}!\""
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about Model Context Protocol SDK (Python)",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "pydantic: Data validation",
        "python-dotenv: .env config loading",
        "uvicorn: ASGI server",
        "fastapi: Web framework",
        "httpx: Async HTTP client",
        "requests: Sync HTTP client"
       ]
      },
      {
       "title": "More in Agent, MCP and tool libraries",
       "path": "tools/agent-libraries/",
       "items": [
        {
         "text": "Model Context Protocol SDK (JavaScript)",
         "path": "tools/modelcontextprotocol/"
        },
        {
         "text": "FastMCP (Python)",
         "path": "tools/fastmcp-pypi/"
        },
        {
         "text": "LangChain",
         "path": "tools/langchain-pypi/"
        },
        {
         "text": "LangGraph",
         "path": "tools/langgraph/"
        },
        {
         "text": "Agent Client Protocol SDK",
         "path": "tools/agentclientprotocol-sdk/"
        },
        {
         "text": "LangChain.js",
         "path": "tools/langchain-npm/"
        },
        {
         "text": "Mastra",
         "path": "tools/mastra/"
        },
        {
         "text": "MCP Inspector",
         "path": "tools/modelcontextprotocol-inspector/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Model Context Protocol SDK (Python)",
       "me": true,
       "facts": [
        "MIT",
        "Gid 83",
        "82M/wk"
       ]
      },
      {
       "name": "Pydantic AI",
       "why": "AI agent framework built with Pydantic for structured, typed agent development.",
       "path": "tools/pydantic-ai/",
       "facts": [
        "MIT",
        "Gid 64",
        "1.8M/wk"
       ]
      },
      {
       "name": "Semantic Kernel",
       "why": "Microsoft SDK for integrating LLMs with traditional code for AI applications.",
       "path": "tools/semantic-kernel/",
       "facts": [
        "MIT",
        "Gid 55",
        "85.6K/wk"
       ]
      }
     ],
     "more": "Compare Model Context Protocol SDK (Python) with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "pip install mcp"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## MCP Python SDK\n- On v2, import `MCPServer` from `mcp.server`. `mcp.server.fastmcp` is the v1 path and fails with `ModuleNotFoundError`.\n- Put type hints on every tool parameter and return value, and write a docstring. The SDK builds the tool schema from them.\n- Install `mcp[cli]` when you need `mcp dev`, `mcp run` or `mcp install`. `mcp dev` also needs `npx` on PATH for the Inspector.\n- Do not pass transport options such as `port` to the `MCPServer` constructor. In v2 that raises `TypeError`.\n- Use `streamable_http_client` (the `streamablehttp_client` alias is removed). Pass `httpx2` objects, not `httpx`, to `http_client=` and `auth=`.\n- In a sync `def` handler, do not call `asyncio.get_running_loop()`. v2 runs sync handlers on a worker thread, so it raises `RuntimeError`.\n- If the project is still on v1, keep `mcp` pinned below 2 until it is migrated.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "pypi mcp"
  ],
  [
   "Category",
   "Agent, MCP and tool libraries"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v2.3.0, October 2, 2026"
  ],
  [
   "On GitHub since",
   "September 2024"
  ],
  [
   "Gid Score",
   "82.7"
  ],
  [
   "Rank in category",
   "#2 of 192"
  ],
  [
   "GitHub",
   "modelcontextprotocol/python-sdk"
  ],
  [
   "Last change",
   "Nov 17, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/modelcontextprotocol.png"
}