-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Gate log notifications on the per-request log-level opt-in at 2026-07-28 #3198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
72ddad4
101e881
84724a4
2636cb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,10 @@ async def countdown(steps: int, ctx: Context) -> dict[str, int]: | |
| try: | ||
| for i in range(1, steps + 1): | ||
| await ctx.report_progress(float(i), float(steps), f"step {i}/{steps}") | ||
| # No non-deprecated logging helper on Context yet, so send the raw | ||
| # notification. `related_request_id` keeps it on this request's response | ||
| # stream (matters over streamable HTTP). | ||
| # Protocol logging is deprecated (SEP-2577), so the raw notification | ||
| # keeps this warning-free. On 2026-07-28+ the client only receives it | ||
| # because it opts in with `log_level=`; `related_request_id` keeps it on | ||
| # this request's response stream (matters over streamable HTTP). | ||
|
Comment on lines
+19
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The rewritten comment claims the client "only receives it because it opts in with Extended reasoning...The bug. This PR rewrites the comment above the raw log send to read: "On 2026-07-28+ the client only receives it because it opts in with The code path. Step-by-step proof. (1) Remove Why it matters. The example teaches the opposite of how the mechanism works. A reader copying this pattern believing the SDK gates the raw path will ship a 2026 server that sends Related staleness. How to fix. Either (a) switch the story's servers to the gated helper — |
||
| await ctx.request_context.session.send_notification( | ||
| types.LoggingMessageNotification( | ||
| params=types.LoggingMessageNotificationParams( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 This new migration section is now contradicted by docs/deprecated.md and docs/whats-new.md, which the PR leaves untouched: deprecated.md's warning box and Recap still name only sampling and roots as the SEP-2577 features that actually stop working on a 2026-07-28 connection ("Nothing breaks today" / "There are no wire changes"), and whats-new.md still says "nothing changes on the wire" — but after this PR, protocol logging on a modern connection (including the default in-process
Client(server)) delivers nothing unless the request opts in. A sentence in deprecated.md's warning box (plus a clause in its Recap and in whats-new.md) linking to this section would restore consistency with the updated callbacks.md.Extended reasoning...
The inconsistency. This PR gates 2026-07-28 log delivery on the per-request
io.modelcontextprotocol/logLevelopt-in and documents that as a breaking change here indocs/migration.mdand indocs/client/callbacks.md("On a 2026-era connection the callback alone gets you nothing"). Butdocs/deprecated.md— the page other docs defer to as the authoritative account of how the SEP-2577-deprecated features behave (docs/handlers/logging.mdpoints readers there) — is not in the diff and still asserts the pre-PR behavior:docs/whats-new.mdlikewise says "deprecated is advisory, everything keeps working against 2025-era sessions, and nothing changes on the wire. What you notice is MCPDeprecationWarning"; the following paragraph mentions thelogging/setLevelremoval but not the opt-in gate.Why it's now wrong. After this PR, on a 2026 connection every protocol-log emitter —
ctx.info()and friends on MCPServer'sContext,ctx.session.send_log_message(...),Context.log— is silently dropped (debug-logged) unless the request's_metacarries the reserved key, andConnection.lognever sends there at all (allowed_log_levelsreturnsfrozenset()withmeta=None). So "nothing changes on the wire" and "only sampling and roots stop working on a modern connection" are both false for logging now, and the PR's own description labels this a breaking change.Concrete walk-through. A reader of deprecated.md builds the default in-process client, which negotiates 2026-07-28: (1)
async with Client(server, logging_callback=on_log)— nolog_level=, since deprecated.md told them logging keeps working with only a warning attached; (2) a tool callsctx.info("progress"); (3)ServerSession._allowed_log_levelsis the empty frozenset (no_metaopt-in on the request), so the notification is dropped with only a server-side debug log; (4)on_lognever fires, and nothing in the page they consulted explains why. Meanwhile the PR-updated callbacks.md says the opposite ("the callback alone gets you nothing") — the docs now disagree with each other about the same behavior.Why nothing else catches it. The PR's doc updates went to
callbacks.mdandmigration.mdonly. AGENTS.md requires updating the relevant page(s) underdocs/in the same PR when a change affects user-visible behavior, anddeprecated.mdis the page dedicated to exactly this feature set's runtime behavior. This is distinct from the other findings on this PR (an example-server comment, theServerSessiondocstring): fixing those leaves these two pages still asserting logging is unaffected at the wire.How to fix. A short paragraph in deprecated.md's warning box noting that at 2026-07-28 protocol logging is additionally gated per-request — dropped unless the request opts in via the reserved
_metakey /Client(log_level=...)— plus a matching clause in the Recap and in whats-new.md, each linking to this migration section ("Log messages are delivered only to requests that opt in").Severity. Nit: docs-only, nothing breaks functionally at merge, and the behavior is documented correctly in migration.md and callbacks.md — this is about the two stale pages contradicting them.