Python SDK
Python SDK for protecting MCP servers and OAuth 2.1 resource servers with tokens issued by the Authplane authorization server. Includes framework adapters (e.g. MCP, FastMCP).
What is Python SDK?
Python SDK is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to python sdk for protecting mcp servers and oauth 2.1 resource servers with tokens issued by the authplane authorization server. includes framework adapters (e.g. mcp, fastmcp).
Python SDK for protecting MCP servers and OAuth 2.1 resource servers with tokens issued by the Authplane authorization server. Includes framework adapters (e.g. MCP, FastMCP).
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Python SDK for protecting MCP servers and OAuth 2.1 resource
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx python-sdkConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Python SDK
The Model Context Protocol Python SDK (modelcontextprotocol/python-sdk) is the official Python library for building MCP servers and clients, providing both a low-level protocol implementation and a high-level FastMCP framework. It supports defining Tools (LLM-callable functions with side effects), Resources (read-only data endpoints), and Prompts (reusable interaction templates), and includes OAuth 2.1 resource server protection via a TokenVerifier interface following RFC 9728. Python developers use this SDK to build production-ready MCP servers that integrate with any MCP-compatible AI client, with options for stdio, HTTP, and SSE transports.
Prerequisites
- Python 3.10 or later installed
- uv (recommended) or pip package manager
- An MCP-compatible client for testing (Claude Desktop, Cursor, or the MCP Inspector CLI)
- Optional: an authorization server URL if using OAuth 2.1 resource server protection
Install the MCP Python SDK
Install the SDK with the CLI extras included (recommended for development and testing). uv is the preferred package manager for MCP projects.
# With uv (recommended)
uv add "mcp[cli]"
# With pip
pip install "mcp[cli]"Create a basic MCP server with FastMCP
Define an MCP server by creating a Python file using the FastMCP class. Add tools with the @mcp.tool() decorator and resources with @mcp.resource().
# server.py
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("My Server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
@mcp.resource("data://greeting/{name}")
def greeting(name: str) -> str:
return f"Hello, {name}!"
if __name__ == "__main__":
mcp.run()Run the server in development mode
Use the MCP CLI to run your server with the MCP Inspector for interactive testing during development.
mcp dev server.pyInstall the server for use with Claude Desktop
Register the server with Claude Desktop directly using the MCP CLI. You can also pass environment variables and .env files during installation.
# Basic install
uv run mcp install server.py
# Install with environment variables
uv run mcp install server.py -v API_KEY=your_key -f .envAdd OAuth 2.1 protection (optional)
Protect your MCP server by implementing a TokenVerifier and configuring AuthSettings. This enables secure token-based access following RFC 9728.
from mcp.server.fastmcp import FastMCP
from mcp.server.auth.provider import TokenVerifier, AccessToken
from mcp.server.auth.settings import AuthSettings
from pydantic import AnyHttpUrl
class MyTokenVerifier(TokenVerifier):
async def verify_token(self, token: str) -> AccessToken | None:
# Validate token against your auth server
if token == "valid-token":
return AccessToken(token=token, scopes=["read"])
return None
mcp = FastMCP(
"Protected Server",
token_verifier=MyTokenVerifier(),
auth=AuthSettings(
issuer_url=AnyHttpUrl("https://auth.example.com"),
resource_server_url=AnyHttpUrl("http://localhost:3001"),
required_scopes=["read"],
),
)Python SDK Examples
Client configuration
claude_desktop_config.json entry for a custom Python MCP server built with this SDK, using uvx to run it.
{
"mcpServers": {
"my-python-server": {
"command": "uv",
"args": ["run", "python", "/path/to/server.py"]
}
}
}Prompts to try
Example prompts for testing a server built with the MCP Python SDK, once it is registered with an MCP client.
- "Use the add tool to calculate 42 + 58"
- "Read the resource at data://greeting/Claude"
- "List all available tools on the my-python-server MCP server"
- "Call the sum tool with a=100 and b=200 and show me the result"
- "What prompts are available on this MCP server?"Troubleshooting Python SDK
'mcp' command not found after 'uv add mcp[cli]'
Run 'uv run mcp' instead of 'mcp' directly, or activate your virtual environment first. If using pip, ensure the Python Scripts directory is in your PATH. On macOS/Linux: 'export PATH=$PATH:$(python -m site --user-base)/bin'.
Server tools are not appearing in Claude Desktop after 'uv run mcp install server.py'
Fully quit and reopen Claude Desktop (not just close the window). The install command writes to claude_desktop_config.json — verify the entry was added correctly by opening the file at ~/Library/Application Support/Claude/claude_desktop_config.json (macOS).
OAuth token verification always returns None / Unauthorized
Ensure your TokenVerifier.verify_token() method returns an AccessToken object (not just True) with valid scopes that match required_scopes in AuthSettings. Log the raw token value received to verify the client is sending the Authorization header correctly.
Frequently Asked Questions about Python SDK
What is Python SDK?
Python SDK is a Model Context Protocol (MCP) server that python sdk for protecting mcp servers and oauth 2.1 resource servers with tokens issued by the authplane authorization server. includes framework adapters (e.g. mcp, fastmcp). It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Python SDK?
Follow the installation instructions on the Python SDK GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Python SDK?
Python SDK works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Python SDK free to use?
Yes, Python SDK is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Python SDK Alternatives — Similar Developer Tools Servers
Looking for alternatives to Python SDK? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Python SDK in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Python SDK?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.