MCP Python SDK

Agent frameworks and SDKs

The official Python SDK for Model Context Protocol servers and clients.

Your AI app calls MCP Python SDK, which does the agent frameworks and SDKs work and sends the result back to the chat.

About MCP Python SDK

MCP Python SDK is the official MCP server from modelcontextprotocol, filed in our directory under agent frameworks and sdks. The official Python SDK for Model Context Protocol servers and clients.

At a glance

Publisher
modelcontextprotocol, the company behind the product
Runs
See the README for setup
Written in
Python
License
MIT
GitHub stars
25,040

How to set up MCP Python SDK

  1. Follow the install steps in the MCP Python SDK README; it is written in Python, so have that toolchain ready.
  2. Check the MCP Python SDK README for keys or settings; the registry lists none that MCP Python SDK requires.
  3. Add MCP Python SDK to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the MCP Python SDK tools to confirm the connection.
  5. Run one read-only task with MCP Python SDK first, and keep your app asking before each tool call until the results look right.

MCP Python SDK compared with similar servers

  • Casdoor by casdoor has fewer GitHub stars than MCP Python SDK (15k against 25k); MCP Python SDK is official while Casdoor is a community server, and both run locally.
  • FastMCP by PrefectHQ has more GitHub stars than MCP Python SDK (28.9k against 25k); MCP Python SDK is official while FastMCP is a community server, and both run locally.
  • Portkey AI Gateway by Portkey-AI has fewer GitHub stars than MCP Python SDK (13.5k against 25k); MCP Python SDK is official while Portkey AI Gateway is a community server, and both run locally.

Before you connect MCP Python SDK

  • Give MCP Python SDK its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each MCP Python SDK tool call until you trust what it does with them.
  • Treat text that MCP Python SDK fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for MCP Python SDK on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for MCP Python SDK

How marketing and sales teams put MCP Python SDK to work, by company size. Pick the size closest to yours and start MCP Python SDK on one use case.

Small business

  • A small business with a developer can use MCP Python SDK to build one focused agent, such as lead follow-up, without a big platform.
  • Technical founders can prototype marketing agents with MCP Python SDK and keep what works as a small, owned tool.
  • MCP Python SDK runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineering teams can use MCP Python SDK to build agents that combine CRM, analytics and content tools behind one workflow.
  • Marketing ops can standardize on MCP Python SDK so every agent they ship has the same logging, approvals and error handling.
  • Start MCP Python SDK on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can build on MCP Python SDK with their own identity, policy and evaluation layers, so agents meet the same bar as other software.
  • Platform teams can use MCP Python SDK to give business units a governed way to ship agents without each one starting from scratch.
  • Because MCP Python SDK comes from modelcontextprotocol, the company behind the product, it follows that product's own auth and permissions, which security teams usually prefer.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

MCP Python SDK README

From modelcontextprotocol/python-sdk on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

MCP Python SDK

Python implementation of the Model Context Protocol (MCP)

Documentation

The documentation lives at https://py.sdk.modelcontextprotocol.io/.

It has a Get started guide, What's new in v2, the API reference, and the migration guide.

What is MCP?

The Model Context Protocol lets you build servers that expose data and functionality to LLM applications in a secure, standardized way. Think of it like a web API, but designed for LLM interactions. With this SDK you can:

  • Build MCP servers that expose tools, resources, and prompts to any MCP host
  • Build MCP clients that connect to any MCP server
  • Speak every standard transport: stdio, Streamable HTTP, and SSE

Requirements

Python 3.11+.

Installation

uv add "mcp[cli]"      # or: pip install "mcp[cli]"

The cli extra adds the mcp command-line tool (mcp dev, mcp run, mcp install) on top of the SDK; install plain mcp if you don't need it. For one-off commands, uv run --with "mcp[cli]" mcp ... works without a project.

A server in 15 lines

Create a server.py:

from mcp.server import MCPServer

mcp = MCPServer("Demo")


@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b


@mcp.resource("greeting://{name}")
def greeting(name: str) -> str:
    """Greet someone by name."""
    return f"Hello, {name}!"

Full example: docs_src/index/tutorial001.py

That's a complete MCP server: one tool, one templated resource. Open it in the MCP Inspector:

uv run mcp dev server.py

Call add with a=1, b=2 and you get 3 back.

Notice what you did not write: no JSON Schema (a: int, b: int is the schema), no request parsing, no validation code, no protocol handling. Two type-hinted Python functions and a docstring.

Get started takes it from here.

A client in 10 lines

The same package is a full MCP client. Serve server.py over HTTP:

uv run mcp run server.py --transport streamable-http

then point a Client at it:

import asyncio

from mcp import Client


async def main() -> None:
    async with Client("http://localhost:8000/mcp") as client:
        result = await client.call_tool("add", {"a": 1, "b": 2})
        print(result.structured_content)  # {'result': 3}


asyncio.run(main())

A URL means Streamable HTTP, the transport you deploy. Client can also launch a local server as a stdio subprocess or take any custom transport; Clients has the rest.

Contributing

We are passionate about supporting contributors of all levels of experience and would love to see you get involved in the project. See the contributing guide to get started.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Questions about MCP Python SDK

What is the MCP Python SDK MCP server?

The official Python SDK for Model Context Protocol servers and clients. MCP Python SDK is published by modelcontextprotocol, the company behind the product, on GitHub at modelcontextprotocol/python-sdk, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the MCP Python SDK MCP server?

MCP Python SDK doesn't publish a one-line install in the MCP registry, so follow the setup steps in its README on GitHub (modelcontextprotocol/python-sdk). Like most servers, MCP Python SDK ends with a command or URL you paste into your AI app's MCP config.

Does MCP Python SDK need an API key?

The registry lists no required keys for MCP Python SDK. Check the MCP Python SDK README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is MCP Python SDK an official MCP server?

Yes. MCP Python SDK is published by modelcontextprotocol, the company that makes the product it connects to, so it follows that product's own API and auth.

What license is MCP Python SDK under?

MCP Python SDK is released under the MIT license, according to its GitHub repository. The license covers the code of MCP Python SDK; the service it connects to has its own terms.