Skip to content

1.0.0

Compare
Choose a tag to compare
@dsp-ant dsp-ant released this 25 Nov 14:22
· 166 commits to main since this release
v1.0.0
91b255f

We're excited to announce the first stable release of the Model Context Protocol (MCP) Python SDK! This release provides a complete implementation of the MCP specification, enabling seamless integration between LLM applications and context providers.

Features

Core Protocol Implementation

  • Full implementation of MCP protocol v2024-11-05
  • Robust client and server capabilities with async/await support
  • Type-safe request/response handling using Pydantic models
  • Support for all core MCP primitives:
    • Prompts and prompt templates
    • Resources and resource templates
    • Tools with JSON Schema validation
    • Progress tracking and notifications
    • Logging with severity levels

Transport Layer Support

  • Standard input/output (stdio) transport
  • Server-Sent Events (SSE) transport

Client Features

  • Simple, intuitive client API
  • Automatic protocol negotiation
  • Request timeout handling
  • Progress tracking
  • Error handling with typed exceptions

Server Features

  • Decorator-based request handlers
  • Built-in capability negotiation
  • Request context management
  • Support for experimental capabilities
  • Automatic request/response routing

Installation

# Using uv (recommended)
uv add mcp

# Using pip
pip install mcp

Basic Usage

Creating a Server

from mcp.server import Server
import mcp.types as types

server = Server("example-server")

@server.list_prompts()
async def handle_list_prompts() -> list[types.Prompt]:
    return [
        types.Prompt(
            name="example-prompt",
            description="An example prompt template",
            arguments=[
                types.PromptArgument(
                    name="arg1", 
                    description="Example argument",
                    required=True
                )
            ]
        )
    ]

# Run the server over stdio
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
    await server.run(
        read_stream,
        write_stream,
        server.create_initialization_options()
    )

Creating a Client

from mcp import ClientSession, StdioServerParameters

async with mcp.client.stdio.stdio_client(
    StdioServerParameters(command="path/to/server")
) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        prompts = await session.list_prompts()

Requirements

  • Python 3.10 or later
  • anyio 4.6 or later
  • pydantic 2.8.0 or later
  • httpx 0.27 or later

Breaking Changes

This is the initial stable release, establishing the baseline API for future versions.

License

MIT License


For more information: