Releases: modelcontextprotocol/python-sdk
v1.8.1
v1.8.0
Streamable HTTP release
This is the first release supporting the new Streamable HTTP transport from protocol version 2025-03-26, which supersedes the SSE transport from protocol version 2024-11-05. 🎉
Please report any issues at https://github.com/modelcontextprotocol/python-sdk/issues
Other Changes
- Handle SSE Disconnects Properly by @akash329d in #612
- Add mount_path support for proper SSE endpoint routing with multiple FastMCP servers by @tim-watcha in #540
- docs: fix broken link to OAuthServerProvider in Authentication section of README by @samad-yar-khan in #651
- Fix the issue of get Authorization header fails during bearer auth by @yabea in #637
- Auth SSE simple example by @ihrpr in #610
- Fix: Use absolute path to uv executable in Claude Desktop config by @arcAman07 in #440
- Introduce a function to create a standard AsyncClient with options by @ihrpr in #655
New Contributors
- @akash329d made their first contribution in #612
- @tim-watcha made their first contribution in #540
- @samad-yar-khan made their first contribution in #651
- @yabea made their first contribution in #637
- @arcAman07 made their first contribution in #440
Full Changelog: v1.7.0...v1.8.0
v1.7.1
Full Changelog: v1.7.0...v1.7.1
v1.7.0
OAuth Support for servers
- Add support for serverside oauth by @praboud-ant in #255
Tool Annotations
- Add ToolAnnotations support in FastMCP and lowlevel servers by @bhosmer-ant in #482
Other changes
-
Docs: Change README to correct pip installation command for MCP CLI support by @codingjenny in #394
-
Fix python -m command error by @xuzexin-hz in #387
-
Docs : Enhance README to suggest commands for creating a new UV project before adding mcp dependency. by @anupsajjan in #408
-
Fix
lifespan_context
access example in README by @SigureMo in #437 -
Fix
@mcp.tool()
Failing to Detect Context Argument When Type Variables Are Used inContext
by @jkawamoto in #358 -
Support custom client info throughout client APIs by @jerome3o-anthropic in #474
-
Fix tests for Pydantic 2.11 by @medaminezghal in #465
-
Python lint: Ruff rules for comprehensions and performance by @cclauss in #512
-
replace inefficient use of
to_jsonable_python
by @samuelcolvin in #545 -
add a timeout arguments on per-request basis (as per MCP specifications) by @grll in #601
-
add pytest-pretty dev dependency by @samuelcolvin in #546
-
Properly clean up response streams in BaseSession by @bhosmer-ant in #515
New Contributors
- @codingjenny made their first contribution in #394
- @xuzexin-hz made their first contribution in #387
- @anupsajjan made their first contribution in #408
- @SigureMo made their first contribution in #437
- @jkawamoto made their first contribution in #358
- @medaminezghal made their first contribution in #465
- @danlapid made their first contribution in #502
- @cclauss made their first contribution in #512
- @grll made their first contribution in #601
- @bhosmer-ant made their first contribution in #482
- @praboud-ant made their first contribution in #255
Full Changelog: v1.6.0...v1.7.0
v1.6.0
What's Changed
- Fix #201: Move incoming message stream from BaseSession to ServerSession by @dsp-ant in #325
- default log level info by @barnuri in #366
- ci: test multiple python versions by @Kludex in #345
- Add mkdocs by @Kludex in #367
- Fix #355: Fix type error with lifespan context by @dsp-ant in #368
- refactor: Make types.py strictly typechecked. by @dsp-ant in #336
- Fix typo in starlette import in README by @conorbranagan in #374
- Fixes to stdio_client to support Windows more robustly by @saqadri in #372
- Fix/base64 handling (Issue #342) by @evalstate in #343
New Contributors
- @barnuri made their first contribution in #366
- @conorbranagan made their first contribution in #374
- @saqadri made their first contribution in #372
- @evalstate made their first contribution in #343
Full Changelog: v1.5.0...v1.6.0
v1.5.0
What's Changed
- Strict types on the client side by @Kludex in #285
- lint docs examples by @samuelcolvin in #286
- Avoid double JSON encoding/decoding by @Kludex in #287
- Improve readability of CLI help option by @Kludex in #295
- Option to mount SSE server to existing ASGI server by @comfuture in #312
- Add callback for logging message notification to client by @ihrpr in #314
- add
cwd
toStdioServerParameters
by @samuelcolvin in #292 - docs(examples): fixing the prompts example by @Niraj-Fonseka in #318
- Add strict mode to pyright by @Kludex in #315
- Enhancement: make stderr of server subprocess configurable by @sheffler in #191
- Update init.py by @arthrod in #335
- Update types.py by @NinoRisteski in #243
- enable custom path of sse server by @elsejj in #246
- Use default environment even when
env
is provided by @maxguru in #327
New Contributors
- @samuelcolvin made their first contribution in #286
- @comfuture made their first contribution in #312
- @ihrpr made their first contribution in #314
- @Niraj-Fonseka made their first contribution in #318
- @arthrod made their first contribution in #335
- @NinoRisteski made their first contribution in #243
- @elsejj made their first contribution in #246
- @maxguru made their first contribution in #327
Full Changelog: v1.4.1...v1.4.2
v1.4.1
v1.4.0
What's Changed
- Update URL validation to allow file and other nonstandard schemas by @hmwildermuth in #207
- Add client handling for sampling, list roots, ping by @jerome3o-anthropic in #218
- Updated typing on request context for the server to use server session by @jerome3o-anthropic in #217
- Fix #177: Returning multiple tool results by @dsp-ant in #222
- Use proper generic for Context by @Kludex in #245
- Drop
AbstractAsyncContextManager
for proper type hint toBaseSession
by @Kludex in #257 - Add ServerSessionT type var to Context by @Kludex in #271
- Create Client websocket.py by @calclavia in #179
- Close unclosed resources in the whole project by @Kludex in #267
- Add support for Linux configuration path in get_claude_config_path by @emsi in #270
- Release on GitHub release by @Kludex in #276
- Changed default log level to error by @Michaelzag in #258
- refactor: reorganize message handling for better type safety and clarity by @dsp-ant in #239
New Contributors
- @hmwildermuth made their first contribution in #207
- @Kludex made their first contribution in #245
- @calclavia made their first contribution in #179
- @emsi made their first contribution in #270
- @Michaelzag made their first contribution in #258
Full Changelog: v1.3.0...v1.4.0
v1.3.0
Python SDK 1.3.0 - 2025-02-20
Breaking Changes
- Context API Changes: The Context logging methods (info, debug, warning, error) are now async and must be awaited. (#172)
New Features
Lifespan Support
Added comprehensive server lifecycle management through the lifespan API:
@dataclass
class AppContext:
db: Database
@asynccontextmanager
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
try:
await db.connect()
yield AppContext(db=db)
finally:
await db.disconnect()
mcp = FastMCP("My App", lifespan=app_lifespan)
@mcp.tool()
def query_db(ctx: Context) -> str:
db = ctx.request_context.lifespan_context["db"]
return db.query()
(#203)
Async Resources
Added support for async resource functions in FastMCP:
@mcp.resource("users://{user_id}")
async def get_user(user_id: str) -> str:
async with client.session() as session:
response = await session.get(f"/users/{user_id}")
return await response.text()
(#157)
Concurrent Request Handling
Made message handling concurrent, allowing multiple requests to be processed simultaneously. (#206)
Request Cancellation
Added support for canceling in-flight requests and cleaning up resources. (#167)
Server Instructions
Added support for the instructions
field in server initialization, allowing servers to provide usage guidance. (#150)
Bug Fixes
- Fixed progress reporting for first tool call by correcting progress_token handling (#176)
- Fixed server crash when using debug logging (#158)
- Fixed resource template handling in FastMCP server (#137)
- Fixed MIME type preservation in resource responses (#170)
- Fixed documentation for environment variables in CLI commands (#149)
- Fixed request ID preservation in JSON-RPC responses (#205)
Dependency Updates
- Relaxed version constraints for better compatibility:
pydantic
: Changed from>=2.10.1,<3.0.0
to>=2.7.2,<3.0.0
pydantic-settings
: Changed from>=2.6.1
to>=2.5.2
uvicorn
: Changed from>=0.30
to>=0.23.1
(#180)
Examples
- Added a simple chatbot example client to demonstrate SDK usage (#98)
Client Improvements
- Added client support for sampling, list roots, and ping requests (#218)
- Added flexible type system for tool result returns (#222)
Compatibility and Platform Support
- Updated URL validation to allow file and other nonstandard schemas (#68fcf92)
- Force stdin/stdout encoding to UTF-8 for cross-platform compatibility (#d92ee8f)
Internal Improvements
- Improved type annotations for better IDE support (#181)
- Added comprehensive tests for SSE transport (#151)
- Updated types to match 2024-11-05 MCP schema (#165)
- Refactored request and notification handling for better code organization (#166)
New Contributors
- @salman1993 made their first contribution in #150
- @micpst made their first contribution in #158
- @3choff made their first contribution in #98
- @cr7258 made their first contribution in #149
- @sheffler made their first contribution in #172
- @jeremydanielfox made their first contribution in #180
- @zzstoatzz made their first contribution in #181
Full Changelog: v1.2.1...v1.3.0
v1.3.0rc1
Python SDK 1.3.0 Release Candidate 1
Breaking Changes
- Context API Changes: The Context logging methods (info, debug, warning, error) are now async and must be awaited. (#172)
- Resource Response Format: Standardized resource response format to return both content and MIME type. Method
read_resource()
now returns a tuple of(content, mime_type)
instead of just content. (#170)
New Features
Lifespan Support
Added comprehensive server lifecycle management through the lifespan API:
@dataclass
class AppContext:
db: Database
@asynccontextmanager
async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]:
try:
await db.connect()
yield AppContext(db=db)
finally:
await db.disconnect()
mcp = FastMCP("My App", lifespan=app_lifespan)
@mcp.tool()
def query_db(ctx: Context) -> str:
db = ctx.request_context.lifespan_context["db"]
return db.query()
(#203)
Async Resources
Added support for async resource functions in FastMCP:
@mcp.resource("users://{user_id}")
async def get_user(user_id: str) -> str:
async with client.session() as session:
response = await session.get(f"/users/{user_id}")
return await response.text()
(#157)
Concurrent Request Handling
Made message handling concurrent, allowing multiple requests to be processed simultaneously. (#206)
Request Cancellation
Added support for canceling in-flight requests and cleaning up resources. (#167)
Server Instructions
Added support for the instructions
field in server initialization, allowing servers to provide usage guidance. (#150)
Bug Fixes
- Fixed progress reporting for first tool call by correcting progress_token handling (#176)
- Fixed server crash when using debug logging (#158)
- Fixed resource template handling in FastMCP server (#137)
- Fixed MIME type preservation in resource responses (#170)
- Fixed documentation for environment variables in CLI commands (#149)
- Fixed request ID preservation in JSON-RPC responses (#205)
Dependency Updates
- Relaxed version constraints for better compatibility:
pydantic
: Changed from>=2.10.1,<3.0.0
to>=2.7.2,<3.0.0
pydantic-settings
: Changed from>=2.6.1
to>=2.5.2
uvicorn
: Changed from>=0.30
to>=0.23.1
(#180)
Examples
- Added a simple chatbot example client to demonstrate SDK usage (#98)