A client constructed without an elicitation_callback or
list_roots_callback still answers the server's request, via a default
callback that returns a JSON-RPC error. Both defaults used -32600
(invalid request). The spec assigns a specific code to each case:
- elicitation/create: -32602 (invalid params). A client with no
callback declares no elicitation modes, so every incoming request
names an undeclared mode, which clients MUST answer with -32602.
- roots/list: -32601 (method not found), the code clients SHOULD use
when they do not support roots.
The default sampling callback keeps -32600: the spec assigns no code
to a client that does not support sampling. Error messages are
unchanged.
Update the affected tests and the interaction-requirement entries that
recorded the old codes, fix the code named in the client callbacks doc
page, and add a migration note.
A request cancelled via notifications/cancelled now gets no response: when
the handler scope's cancel is caught, JSONRPCDispatcher returns instead of
writing an error. The sender retired its own waiter when it cancelled, so
no reply is needed to unblock it.
An unhandled exception in a request handler now produces JSON-RPC error
-32603 (INTERNAL_ERROR) with the opaque message "Internal server error"
instead of code 0 carrying str(exc). The exception is still logged
server-side. To send a specific code/message, raise MCPError; pydantic
ValidationError still maps to INVALID_PARAMS.
handler_exception_to_error_data is now total: it returns
MappedError(error: ErrorData, unexpected: bool) for every Exception.
Callers gate logger.exception / raise_handler_exceptions on the
unexpected flag rather than re-deriving the rung set, so a handler that
deliberately raises MCPError(code=INTERNAL_ERROR) is not treated as a
crash. JSONRPCDispatcher, DirectDispatcher, and the modern HTTP entry's
_to_jsonrpc_response all call the one helper; DirectDispatcher no longer
hand-rolls its own ladder.
The interaction suite's protocol:cancel:in-flight and
protocol:error:internal-error requirements drop their divergence entries
and modern-error-surface arm exclusions; the two prompt-validation
divergence notes are reworded for the new -32603 surface.
docs/migration.md gains a section covering both behaviour changes.