Fix isJsonRpcError mis-classifying {result,error:null} + envelope check (110->124) - #11
Merged
Merged
Conversation
…0.2.1)
The shared isJsonRpcError() classifier used a bare `"error" in response`
test, which misclassifies the `{ jsonrpc, id, result, error: null }` shape
— a common serialiser default — as an error. That turned passing tool
roundtrips into spurious FAIL/WARN across the smoke/schema/capability/
version suites. A wrong conformance verdict is worse than a missing check.
Per JSON-RPC 2.0 §5 and the MCP `Error` interface, an error response carries
an `error` member that is an object with a numeric `code`; a success response
carries `result` and omits `error`. isJsonRpcError() now enforces exactly
that, matching the HTTP adapter's own envelope detection (verified against
the current spec via context7 /websites/modelcontextprotocol_io_specification_2025-11-25).
Also adds a `jsonrpc-response-envelope` check (result/error mutual
exclusivity — no prior suite caught `{ result, error: {...} }`), migrates
vitest.config off the removed-in-v4 nested poolOptions, and bumps to 0.2.1.
Tests: +tests/jsonrpc-helpers.test.ts (10 cases) + hybrid-envelope-server
fixture + 4 integration tests proving error:null is treated as success by
smoke/schema yet warned by the envelope check. 110 -> 124 tests, all green.
build + tsc --strict clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Conformance-harness correctness + coverage. Spec checked against current MCP 2025-11-25 via context7 (already supported correctly).
isJsonRpcError()(used by every suite) used"error" in response, so the common{result, error: null}success shape was misclassified as an error -> spurious FAIL/WARN for conformant servers. Tightened to require a non-null error object with a numeric code.jsonrpc-response-envelopecheck (result/error mutual exclusivity).poolOptions.Tests 110 -> 124. Version 0.2.0 -> 0.2.1. No publish in this PR.