Log MCPServer handler exceptions by kind and keep crash details off the wire (#3314)
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
This commit is contained in:
parent
f1c40b062f
commit
56af44727b
1 changed files with 1427 additions and 310 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Deprecated features
|
||||
|
||||
The 2026-07-28 spec retires five things. The SDK still implements every one of them, and every one of them now carries a **deprecation warning**.
|
||||
The 2026-07-28 spec retires five things. The SDK still implements every one of them, and every one of them now carries a **deprecation warning**. One SDK helper is deprecated on its own account and is listed [at the end](#deprecated-sdk-helpers).
|
||||
|
||||
The table below names each deprecated feature, why it is going away, and the replacement to build on.
|
||||
|
||||
|
|
@ -119,15 +119,24 @@ That is the whole API. There is no per-method switch, and you don't want one: th
|
|||
Run the filter the other way and you get a free regression test. Add
|
||||
`"error::mcp.MCPDeprecationWarning"` to the `filterwarnings` setting in your pytest
|
||||
configuration and the deprecated call **raises** instead of warning. A tool named
|
||||
`old_log` that still calls `ctx.info()` stops passing and starts reporting:
|
||||
`old_log` that still calls `ctx.info()` stops passing: the call comes back `is_error=True` with
|
||||
`Error executing tool old_log`, and the captured server log names the culprit:
|
||||
|
||||
```text
|
||||
Error executing tool old_log: The logging capability is deprecated as of 2026-07-28 (SEP-2577).
|
||||
mcp.shared.exceptions.MCPDeprecationWarning: The logging capability is deprecated as of 2026-07-28 (SEP-2577).
|
||||
```
|
||||
|
||||
One line of pytest configuration, and a deprecated call can never sneak back into your
|
||||
codebase without failing a test.
|
||||
|
||||
## Deprecated SDK helpers
|
||||
|
||||
These are not spec changes, only SDK internals with a better replacement. They warn with the same `MCPDeprecationWarning` and will be removed in 3.0.
|
||||
|
||||
| Deprecated | What you do instead |
|
||||
|---|---|
|
||||
| `FuncMetadata.call_fn_with_arg_validation()` | `FuncMetadata.validate_arguments()` and then `FuncMetadata.call_fn()`. Only code that drives `FuncMetadata` directly (a custom `Tool` subclass, say) ever called it. |
|
||||
|
||||
## Recap
|
||||
|
||||
* The 2026-07-28 spec deprecates **roots**, server-initiated **sampling**, and protocol **logging** (all [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577)), restricts **progress** to server-to-client, and removes **`ping`**.
|
||||
|
|
@ -135,6 +144,7 @@ That is the whole API. There is no per-method switch, and you don't want one: th
|
|||
* Deprecated is advisory: no wire changes, everything keeps working against pre-2026 sessions, and you get a visible `MCPDeprecationWarning` (a `UserWarning`, so it is on by default).
|
||||
* Sampling and roots additionally need a back-channel that a 2026-07-28 session does not have. On a modern connection they warn and then they raise.
|
||||
* `warnings.filterwarnings("ignore", category=MCPDeprecationWarning)` silences the whole category; `"error::mcp.MCPDeprecationWarning"` in pytest turns it into a test failure.
|
||||
* One SDK helper, `FuncMetadata.call_fn_with_arg_validation()`, is deprecated separately for removal in 3.0.
|
||||
* New code should not be built on any of these.
|
||||
|
||||
Every other page in these docs teaches the current API.
|
||||
|
|
|
|||
Loading…
Reference in a new issue