python-sdk  by modelcontextprotocol

Python SDK for Model Context Protocol (MCP) servers/clients

Created 11 months ago
18,552 stars

Top 2.4% on SourcePulse

GitHubView on GitHub
Project Summary

The Model Context Protocol (MCP) Python SDK provides a standardized way for applications to expose data and functionality to Large Language Models (LLMs). It enables developers to build both MCP clients and servers, facilitating secure and structured LLM interactions by separating context provision from LLM execution.

How It Works

MCP defines three core primitives: Resources (data exposure, like GET endpoints), Tools (functionality, like POST endpoints), and Prompts (reusable interaction templates). The SDK's FastMCP server class simplifies creating servers that expose these primitives via Python decorators. It handles protocol compliance, message routing, and supports features like lifespan management for resource initialization and cleanup, enabling type-safe context passing between server startup and tool execution.

Quick Start & Requirements

Highlighted Details

  • Standardization: Implements the full MCP specification for interoperability.
  • Flexibility: Supports creating MCP servers and clients, with options for direct execution or mounting into existing ASGI applications.
  • Developer Experience: Offers high-level abstractions (FastMCP) and low-level server implementations for custom control.
  • Integration: Includes examples for Claude Desktop integration and common patterns like database access.

Maintenance & Community

  • Active development with a clear contribution guide.
  • Links to GitHub Discussions are provided for community interaction.

Licensing & Compatibility

  • MIT License. Permissive for commercial use and integration with closed-source projects.

Limitations & Caveats

The SDK is actively developed, and some features might be experimental or subject to change. Specific LLM integrations or advanced protocol features may require deeper understanding of the MCP specification.

Health Check
Last Commit

16 hours ago

Responsiveness

1 day

Pull Requests (30d)
56
Issues (30d)
59
Star History
975 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.