Skip to content

feat: add conformance scenarios for 2026-07-28 stream cancellation and per-request logLevel - #438

Open
elang2 wants to merge 1 commit into
modelcontextprotocol:mainfrom
elang2:feat/stateless-http-cancellation
Open

feat: add conformance scenarios for 2026-07-28 stream cancellation and per-request logLevel#438
elang2 wants to merge 1 commit into
modelcontextprotocol:mainfrom
elang2:feat/stateless-http-cancellation

Conversation

@elang2

@elang2 elang2 commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Adds two new conformance scenarios targeting the MCP 2026-07-28 specification:

  • HTTP Stream-Close Cancellation — validates that closing the SSE response stream acts as request cancellation (replacing notifications/cancelled on HTTP transport)
  • Per-Request LogLevel — validates _meta.io.modelcontextprotocol/logLevel filtering, scoping, and invalid value rejection

Both scenarios use introducedIn: DRAFT_PROTOCOL_VERSION and run only under --suite draft or --spec-version 2026-07-28, excluded from default CI until the spec is published as a dated release.

Scenarios Added

http-stream-cancellation (3 checks)

  1. Stream close = cancellation — server handles mid-flight SSE disconnect gracefully
  2. Server health after cancellation — server remains operational after client aborts
  3. Rapid burst stability — 5 rapid open+close cycles don't crash/deadlock the server

per-request-loglevel (4 checks)

  1. Positive emissionnotifications/message emitted when logLevel is set (WARNING if server opts out)
  2. Severity filtering — MUST NOT deliver messages below requested level
  3. Invalid logLevel rejection — SHOULD respond with -32602 for unrecognized values
  4. Request-scoped delivery — logs MUST appear only on the requesting stream, not concurrent ones

Design Decisions

  • Uses raw fetch with AbortController (not SDK client) to precisely control stream lifecycle
  • Tracks serverEmitsLogs flag to SKIP filtering/scoping checks when server never emits (avoids false positives on servers that don't implement logging)
  • Per-iteration timeouts in burst loop prevent hangs if server is overwhelmed
  • Check 4 aborts the logging request's stream before consuming to prevent indefinite SSE hang

Test plan

  • TypeScript compiles cleanly (npx tsc --noEmit)
  • ESLint passes
  • Scenarios correctly filtered into draftClientScenariosList via introducedIn check
  • Validated by 6 independent review agents (spec compliance, code quality, hang prevention, false-positive analysis)

Spec References

…narios

Add two new conformance scenarios targeting the 2026-07-28 spec:

- http-stream-cancellation: Tests that closing an SSE response stream is
  treated as cancellation (the 2026-07-28 transport-level mechanism replacing
  notifications/cancelled on HTTP). Verifies server stops sending after
  disconnect, remains healthy, and handles rapid burst disconnects.

- per-request-loglevel: Tests per-request log level filtering via
  _meta.io.modelcontextprotocol/logLevel. Validates positive emission,
  severity filtering, invalid level rejection, and request-scoped delivery.

Both use introducedIn: DRAFT_PROTOCOL_VERSION and run under --suite draft.
@elang2 elang2 changed the title feat: conformance scenarios for MCP 2026-07-28 stream cancellation and per-request logging feat: add conformance scenarios for 2026-07-28 stream cancellation and per-request logLevel Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant