You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Lowlevel `Server`: decorator-based handlers replaced with `RequestHandler`/`NotificationHandler`
410
410
411
-
### `streamable_http_app()` available on lowlevel Server
411
+
The lowlevel `Server` class no longer uses decorator methods for handler registration. Instead, handlers are `RequestHandler` and `NotificationHandler` objects passed to the constructor or added via `add_handler()`.
412
412
413
-
The `streamable_http_app()` method is now available directly on the lowlevel `Server` class, not just `MCPServer`. This allows using the streamable HTTP transport without the MCPServer wrapper.
- Handlers receive `(ctx, params)` instead of the full request object or unpacked arguments. `ctx` is a `RequestHandlerContext` (for requests) or `NotificationHandlerContext` (for notifications) with `session`, `lifespan_context`, and `experimental` fields. `params` is the typed request params object.
470
+
- Handlers return the full result type (e.g. `ListToolsResult`) rather than unwrapped values (e.g. `list[Tool]`).
### Lowlevel `Server`: `request_context` property and `request_ctx` contextvar removed
496
+
497
+
The `server.request_context` property and the `request_ctx` module-level contextvar have been removed. Request context is now passed directly to handlers as the first argument (`ctx`).
498
+
499
+
**Before (v1):**
500
+
501
+
```python
502
+
from mcp.server.lowlevel.server import request_ctx
-`NotificationHandlerContext(HandlerContext)` — empty subclass for notifications
534
+
535
+
**Before (v1):**
536
+
537
+
```python
538
+
from mcp.shared.context import RequestContext
539
+
```
540
+
541
+
**After (v2):**
542
+
543
+
```python
544
+
from mcp.shared.context import HandlerContext, RequestHandlerContext, NotificationHandlerContext
545
+
```
546
+
547
+
## New Features
548
+
549
+
### `streamable_http_app()` available on lowlevel Server
550
+
551
+
The `streamable_http_app()` method is now available directly on the lowlevel `Server` class, not just `MCPServer`. This allows using the streamable HTTP transport without the MCPServer wrapper.
552
+
553
+
```python
554
+
from mcp.server.lowlevel import Server, RequestHandler
555
+
from mcp.shared.context import RequestHandlerContext
556
+
from mcp.types import ListToolsResult, PaginatedRequestParams
0 commit comments