Gate log notifications on the per-request log-level opt-in at 2026-07-28 (#3198)
This commit is contained in:
parent
b61ce388dd
commit
89c5e700f2
2 changed files with 406 additions and 31 deletions
|
|
@ -15,7 +15,9 @@ async def main(target: Target, *, mode: str = "auto") -> None:
|
|||
async def on_log(params: LoggingMessageNotificationParams) -> None:
|
||||
logs.append(params)
|
||||
|
||||
async with Client(target, mode=mode, logging_callback=on_log) as client:
|
||||
# `log_level` is the 2026-07-28 per-request opt-in: without it a modern server
|
||||
# sends no log notifications at all (pre-2026 servers ignore it and send anyway).
|
||||
async with Client(target, mode=mode, logging_callback=on_log, log_level="info") as client:
|
||||
# ── progress + logging: a short countdown delivers exactly `steps` of each, in order ──
|
||||
updates: list[tuple[float, float | None, str | None]] = []
|
||||
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@ def build_server() -> MCPServer:
|
|||
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).
|
||||
await ctx.request_context.session.send_notification(
|
||||
types.LoggingMessageNotification(
|
||||
params=types.LoggingMessageNotificationParams(
|
||||
|
|
|
|||
Loading…
Reference in a new issue