MCP Python SDK
Official MIT-licensed Python SDK for the Model Context Protocol — build MCP servers and clients with full spec compliance.
MCP Python SDK
The MCP Python SDK is the official reference implementation of the Model Context Protocol from Anthropic's modelcontextprotocol organization. It provides the full low-level API for building both MCP servers (expose tools, resources, prompts) and MCP clients (connect to any MCP server), with complete spec compliance and async support.
Key features
- Full MCP spec implementation: tools, resources, resource templates, prompts, sampling, roots
- Both server and client APIs in one package
- Stdio and SSE transport support
- Async-first using Python's asyncio + anyio
- Pydantic models for all protocol messages — fully typed
- MIT license — use in any project, commercial or open-source
Quick start (server)
pip install mcp
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import Tool, TextContent
app = Server("my-server")
@app.list_tools()
async def list_tools():
return [Tool(name="echo", description="Echo a message", inputSchema={
"type": "object",
"properties": {"message": {"type": "string"}},
"required": ["message"]
})]
@app.call_tool()
async def call_tool(name: str, arguments: dict):
if name == "echo":
return [TextContent(type="text", text=arguments["message"])]
async def main():
async with stdio_server() as (r, w):
await app.run(r, w, app.create_initialization_options())
import asyncio; asyncio.run(main())
Install via ai-supply
npx ai-supply add mcp-python-sdk
Curated mirror of the open-source MCP Python SDK (MIT). Get it from the source.
Compromise signals — malicious or tampered code (leaked secrets, backdoors, a dropped executable) — reduce the score, and known dependency CVEs carry a bounded penalty (they warrant review but never QUARANTINE — update the dependency to clear). Other dangerous-by-capability traits are risk surface, expected for some capabilities. Every finding is mapped to its OWASP control below.
Findings mapped to the OWASP Top 10 for LLM Applications (2025) and the OWASP Machine Learning Security Top 10. Expand any flagged control for the exact findings — compromise reduces the score; expected/risk-surface do not, except a known CVE, which carries a small bounded penalty (high/critical → Review).
The same gate an agent runs before installing (POST /api/v1/trust/mcp-python-sdk/check). Click a policy:
Consume MCP Python SDK programmatically. Authenticate with an API key or session — see Authorize an agent.
# Agents: CHECK BEFORE YOU INSTALL (no auth) — score, grade, level, capability manifest
curl https://ai-supply.store/api/v1/trust/mcp-python-sdk
# Gate against your org policy (returns { pass, violations })
curl -X POST https://ai-supply.store/api/v1/trust/mcp-python-sdk/check \
-H "Content-Type: application/json" \
-d '{"minGrade":"B","denyPermissions":["shell"],"denyUnknownEgress":true}'
# CLI
npx ai-supply add mcp-python-sdk
# REST (install → download)
curl -X POST https://ai-supply.store/api/v1/listings/mcp-python-sdk/install \
-H "Authorization: Bearer $AIM_KEY"
# MCP tool
install_listing({ "slug": "mcp-python-sdk" })OpenAPI spec →Curated mirror — latest upstream source. See the repository for tagged releases.