python-sdk
The official Python SDK for Model Context Protocol servers and clients
claude mcp add --transport stdio modelcontextprotocol-python-sdk uvx mcp
How to use
The MCP Python SDK allows developers to create and manage servers that expose data and functionality for LLM applications. With this SDK, you can build MCP clients that connect to any MCP server, create servers that expose resources, prompts, and tools, and utilize standard transports like stdio, SSE, and Streamable HTTP. The SDK also provides functionalities for handling protocol messages and lifecycle events, making it a comprehensive solution for integrating LLMs with context management.
To use the tools provided by the MCP Python SDK, you can create a server that defines various resources and tools. For example, you can create a calculator tool that performs arithmetic operations or define resources that return personalized greetings. The SDK supports running servers in different modes, including development mode and integration with existing ASGI servers, allowing for flexibility in deployment and usage.
How to install
- Ensure you have Python installed on your machine. You can download it from https://www.python.org/downloads/.
- Install the
uvpackage by running:pip install uv - Create a new
uvmanaged project:uv init mcp-server-demo cd mcp-server-demo - Add the MCP SDK to your project dependencies:
uv add "mcp[cli]" - To run the MCP command, use:
uv run mcp
Additional notes
When running the server, ensure that the transport mode is correctly set for your use case, such as streamable HTTP. If you encounter issues, check the server logs for any error messages that can guide you in troubleshooting. Additionally, consider configuring environment variables for sensitive data or settings that may vary between development and production environments.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP