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
Dispatcher:
- notify omits the params key entirely when params is None; the spec
requires absent over null and the TS SDK client rejects null.
- transport_builder calls on the read-loop path are guarded: a raising
builder answers the request with INTERNAL_ERROR (or drops the
notification) instead of killing the dispatcher.
- bool no longer matches the int() structural patterns (progressToken,
cancelled requestId, progress), so true cannot alias to request id 1.
The cancelled arm and the _in_flight table now coerce ids the same way
responses do, so string/int id forms correlate both ways.
- Dropped the redundant outer _in_flight pop in _handle_request; it
could evict a newer request that reused the id. Resumption hints
passed alongside related_request_id are dropped with a debug log and
the precedence is documented.
- notifications/cancelled now flows through to on_notify after the
dispatcher applies its cancellation, so Server.middleware observes it
and servers can register custom handling.
Runner / peer:
- dump_params serializes meta through RequestParams by alias (the
inverse of _extract_meta), so a handler passing meta=ctx.meta emits
progressToken on the wire, not progress_token.
- A handler returning ErrorData now raises MCPError inside call_next()
so middleware observes the failure; _dump_result keeps the conversion
as a backstop for middleware that itself returns ErrorData.
docs/migration.md: middleware example takes the raw mapping; remove the
unreachable DispatchMiddleware pointer; fix the inverted
raise_exceptions claim.
@@ -856,11 +855,11 @@ server = Server("my-server", on_call_tool=...)
856
855
server.middleware.append(logging_middleware)
857
856
```
858
857
859
-
For lower-level interception (raw method/params before validation, including unknown methods), use `DispatchMiddleware` from `mcp.shared.dispatcher`.
858
+
Middleware runs before params validation, so `params` is the raw inbound mapping (or `None`), and it also wraps unknown methods.
860
859
861
860
### Lowlevel `Server.run(raise_exceptions=True)`: transport errors no longer re-raised
862
861
863
-
`raise_exceptions=True` now only governs handler exceptions: an exception raised by an `on_*` handler propagates out of `run()` instead of being converted to a JSON-RPC error response.
862
+
`raise_exceptions=True` now only governs handler exceptions: an exception raised by an `on_*` handler propagates out of `run()`. The JSON-RPC error response is still written to the client first, regardless of the flag.
864
863
865
864
Previously it also re-raised exceptions yielded by the transport onto the read stream (e.g. JSON parse errors). Those are now debug-logged and dropped regardless of `raise_exceptions`. If you relied on `run()` exiting on a transport-level parse error, that no longer happens.
866
865
@@ -1115,7 +1114,7 @@ In practice, replace direct `ServerSession` use with `Server.run(read_stream, wr
1115
1114
-`ServerRequestResponder` type alias.
1116
1115
-`ServerSession.incoming_messages` stream — there is no longer a public stream of inbound messages to iterate. Register handlers via the `on_*` constructor params (or `add_request_handler`) and use `Server.middleware` to observe every inbound request and notification (`initialize`, unknown methods, validation failures, and `notifications/initialized` included).
1117
1116
-`ServerSession.__aenter__` / `__aexit__` — `ServerSession` is no longer an async context manager.
1118
-
- The private `_receive_loop`, `_received_request`, `_received_notification`, and `_handle_incoming` overrides — there is nothing to override on `ServerSession` anymore. To intercept inbound messages, use `Server.middleware`or `DispatchMiddleware`(see the `_handle_*` removal section above).
1117
+
- The private `_receive_loop`, `_received_request`, `_received_notification`, and `_handle_incoming` overrides — there is nothing to override on `ServerSession` anymore. To intercept inbound messages, use `Server.middleware` (see the `_handle_*` removal section above).
0 commit comments