Python SDK

v1.0.0Developer Toolsstable

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-sdkmcpai-integration
Share:
23,088
Stars
0
Downloads
0
Weekly
0/5

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

Protect MCP servers and OAuth 2.1 resource servers with secure tokens.
Use framework adapters like MCP and FastMCP for Python applications.
LicenseMIT
Languagepython
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx python-sdk

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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]"
2

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()
3

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.py
4

Install 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 .env
5

Add 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.

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.

Quick Config Preview

{ "mcpServers": { "python-sdk": { "command": "npx", "args": ["-y", "python-sdk"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides