SDK Guide

Python MCP SDK: Complete Developer Guide

Python MCP SDK is covered here as a Model Context Protocol SDK guide page: what it is, how it works, when to use it, how to configure it safely, and how to verify the result. The guidance is grounded in the official MCP specification, SDK documentation, and ve

Overview

The Python MCP SDK is the official library for building MCP servers in Python. It supports tools, resources, prompts, transports, and the stdio and streamable-http transport.

Installation

pip install mcp

Minimal Server Example

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("my-server")

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

if __name__ == "__main__":
    mcp.run(transport="stdio")

Adding a Tool

Tools are the primary way MCP servers expose functionality to clients. Each tool has a name, input schema, and handler function.

@mcp.tool()
async def get_weather(city: str) -> dict:
    """Get weather for a city."""
    return await fetch_weather(city)

Supported Features

tools
resources
prompts
transports

Testing Your Server

  1. Start the server and verify it prints no startup errors.
  2. Run npx @modelcontextprotocol/inspector and connect over stdio.
  3. Call your tools and verify they return the expected responses.
  4. Connect from Claude Desktop and confirm tool visibility.
M
MCPServer.in Editorial

Editorial Team

Published: 2026-08-05
Updated: 2026-08-05

References & Technical Specifications

Frequently Asked Questions

Contextual information and technical support details regarding Model Context Protocol integration