M
modelcontextprotocol/python-sdk
Official Python SDK for MCP servers and clients
在 GitHub 查看 ↗链接已于 2026-11-12 核查 · HTTP 200 · 打开的是厂商自己的官网
我们没有从该仓库取到可核对的安装命令,也没有公开的远端端点。这两样都没有时,我们不出配置——编一条出来比不给更糟。 各客户端的接法 →
- 来源明细
- 收录自 abordage/awesome-mcp 榜单(我们从中收集的条目之一) · 条目类型:MCP 服务
- 收录与活跃
- 收录于 2026-11-05 · 最近见到 2026-11-14 · 共见到 10 次 · 被 10 个来源列出
- 评分构成
- 综合分 1,003 · 10 个来源 · mcp
常见问题(答案都来自我们的记录)
它适合谁 / 用来做什么?
我们把它归在这些标签下: MCP 服务。标签来自条目自身,不是我们强加的分类。
谁维护它、还在更新吗?
我们收录于 2026-11-05;最近见到 2026-11-14。这里没有"官方认证"或"质量评级"——我们只记录来源与时间。
# MCP Python SDK
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Python implementation of the Model Context Protocol (MCP)
[![PyPI][pypi-badge]][pypi-url]
[![MIT licensed][mit-badge]][mit-url]
[![Python Version][python-badge]][python-url]
[![Documentation][docs-badge]][docs-url]
[![Protocol][protocol-badge]][protocol-url]
[![Specification][spec-badge]][spec-url]
## Documentation
The documentation lives at .
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
bash
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:
python
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: docssrc/index/tutorial001.py
That's a complete MCP server: one tool, one templated resource. Open it in the MCP Inspector:
bash
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:
bash
uv run mcp run server.py --transport streamable-http
then point a Client at it:
python
import asyncio
from mcp import Client
async def main() -> None:
async with Client("http://localhost:8000/mcp") as client:
result = await client.calltool("add", {"a": 1, "b": 2})
print(result.structuredcontent) # {'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.
[![PyPI][pypi-badge]][pypi-url]
[![MIT licensed][mit-badge]][mit-url]
[![Python Version][python-badge]][python-url]
[![Documentation][docs-badge]][docs-url]
[![Protocol][protocol-badge]][protocol-url]
[![Specification][spec-badge]][spec-url]
## Documentation
The documentation lives at .
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
bash
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:
python
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: docssrc/index/tutorial001.py
That's a complete MCP server: one tool, one templated resource. Open it in the MCP Inspector:
bash
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:
bash
uv run mcp run server.py --transport streamable-http
then point a Client at it:
python
import asyncio
from mcp import Client
async def main() -> None:
async with Client("http://localhost:8000/mcp") as client:
result = await client.calltool("add", {"a": 1, "b": 2})
print(result.structuredcontent) # {'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.
收录徽章(可选)
想把收录标记放进 README 就复制这行,可选,不影响收录。
[](https://anclum.com/zh/s/modelcontextprotocol-python-sdk/)
- 来源
- awesome · https://github.com/modelcontextprotocol/python-sdk
- 按领域浏览
- MCP 服务
- 收录来源
- 10 个独立来源
- 收录于
- 今天
同类推荐
所属领域与标签
每个标签都能点进去看同类的全部条目。数字是当前库里的真实条数。