python-sdk
python-sdk copied to clipboard
The official Python SDK for Model Context Protocol servers and clients
### Description ## Summary Server and client sessions use an internal initialization state machine combined with various flags and manual `AsyncExitStack` management. Stateless mode complicates this further by setting an...
## Summary The SDK currently implements multiple server and client transports (stdio, SSE, WebSocket, Streamable HTTP). Each one has its own message loop, error handling, and resource management logic with...
### Description ## Summary FastMCP provides a higher-level API over the low-level MCP server, but the layering between them is currently leaky: - FastMCP wraps an internal `_mcp_server` object and...
### Description ## Summary Tools and resources can currently return arbitrary content (text, JSON, etc.) that is forwarded directly to clients and often to LLMs. There is no built-in way...
### Description ### Context https://github.com/modelcontextprotocol/python-sdk/pull/1685 implemented server-wide tool execution timeouts with a default of 300 seconds. ### Motivation Some tools may need different timeout values: - Quick lookups: `get_weather()` -...
## Summary Implements baseline timeout behavior for MCP tool calls to prevent indefinite blocking. Closes #1374 ## Changes ### Server-Side Timeout - **Added REQUEST_TIMEOUT error code** (-32001) to `src/mcp/types.py` -...
### Initial Checks - [x] I confirm that I'm using the latest version of MCP Python SDK - [x] I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before...
### Description ## Summary The Python SDK currently uses a global `contextvars.ContextVar` (e.g. `request_ctx`) to hold per-request state for the server. This enables convenience helpers like `get_request_context()`, but it also...
### Description I have an idea to make the Tool syntax like this: ```py from mcp.types import Tool @Tool(name="hello", description="Say hello back") def hello(): return [TextContent(type="text", text="Hello")] ``` Why? Because...
### Description ### Summary The current Python SDK docs and examples focus on minimal, single-file servers (e.g. `weather.py` with all tools in one module). This is great for getting started...