Skip to content

Add json-rpc-batch-rejection scenario for 2025-06-18+#381

Open
canardleteer wants to merge 1 commit into
modelcontextprotocol:mainfrom
canardleteer:fix/378-json-rpc-batch-rejected
Open

Add json-rpc-batch-rejection scenario for 2025-06-18+#381
canardleteer wants to merge 1 commit into
modelcontextprotocol:mainfrom
canardleteer:fix/378-json-rpc-batch-rejected

Conversation

@canardleteer

Copy link
Copy Markdown

Closes #378

Summary

  • Adds server scenario json-rpc-batch-rejection with check json-rpc-batch-rejected for spec versions ≥ 2025-06-18, exercising the Streamable HTTP transport MUST that the POST body be a single JSON-RPC message (not a JSON array).
  • Probe establishes a stateful session, then POSTs a two-request [ping, ping] batch so rejection is tested on batch handling rather than unrelated session routing errors.
  • Adds negative fixture accepts-json-rpc-batch.ts, unit tests for acceptance/rejection helpers, and an early array guard in everything-server so the reference server passes all-scenarios.test.ts (documented in code — negative proof remains in the broken fixture per AGENTS.md).

Test plan

  • npm run build
  • npm test (338 tests, including all-scenarios.test.ts / json-rpc-batch-rejection)
  • npm test -- src/scenarios/server/negative.test.ts (json-rpc-batch-rejectedFAILURE against accepts-json-rpc-batch.ts)
  • npm test -- src/scenarios/server/json-rpc-batch-rejection.test.ts
  • CLI smoke: node dist/index.js server --url http://127.0.0.1:<port>/mcp --scenario json-rpc-batch-rejection --spec-version 2025-11-25 against everything-serverSUCCESS
  • CLI run against typescript-sdk conformance server — node dist/index.js sdk typescript-sdk-v1 --mode server --scenario json-rpc-batch-rejection --spec-version 2025-11-25json-rpc-batch-rejected FAILURE (typescript-sdk v1.x accepts batch arrays at 2025-11-25; intentional Tier-1 signal for that spec version until the SDK fixes batch rejection)
  • Confirm scenario absent for --spec-version 2025-03-26 — CLI: SKIPPED: … not applicable … (introduced in 2025-06-18), exit 0
  • --spec-version draft run against everything-server → json-rpc-batch-rejected SUCCESS (stateless draft batch probe)

Notes for reviewers

  • Spec backing: MUST-level requirement from transports prose, not changelog narrative alone. Changelog linked as supporting context.
  • Success criteria: HTTP 4xx with a single JSON-RPC error object (not strict -32600) until SDKs converge on error codes.
  • Tier-1 impact (2025-06-18+ / draft only): This scenario is gated to spec versions where batch rejection is required; --spec-version 2025-03-26 skips it entirely.
    • Tier-1 conformance is evaluated per target spec version — when an SDK is scored at 2025-06-18+ (or draft) and its server still accepts batch arrays after session setup, it should fail until fixed.
    • SDKs not ready to reject batches yet can stay in good standing by tier-checking at an older --spec-version (or otherwise explicitly opting out of claiming full conformance at 2025-06-18+). The check is active, not pending; the margin is which spec version the SDK holds itself to.
  • everything-server change: Reference-server alignment for all-scenarios; failure proof is the separate negative fixture.

…-06-18+

Add server scenario with check json-rpc-batch-rejected for spec versions
where POST bodies MUST be a single JSON-RPC message. Stateful probe
initializes a session before posting a [ping, ping] batch; draft uses a
stateless two-method batch. Includes negative fixture, unit tests, vitest
with draft lifecycle and acceptance details, and everything-server array
guard for all-scenarios.test.ts.

Fixes modelcontextprotocol#378
@canardleteer canardleteer force-pushed the fix/378-json-rpc-batch-rejected branch from d928845 to 0cf3fe0 Compare July 2, 2026 18:12
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.

Add conformance test (2025-06-18+): servers MUST reject JSON-RPC batch requests

1 participant