fix: use unprefixed message for JSON-RPC wire serialization (-32042)#1578
Open
evalstate wants to merge 2 commits intomodelcontextprotocol:mainfrom
Open
fix: use unprefixed message for JSON-RPC wire serialization (-32042)#1578evalstate wants to merge 2 commits intomodelcontextprotocol:mainfrom
evalstate wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
ProtocolError constructor sets Error.message to 'MCP error {code}: {message}'
for developer DX, but protocol.ts was using this prefixed string as the
JSON-RPC error.message on the wire. This caused:
1. Non-spec-conformant wire messages (spec examples show clean messages)
2. Double-prefixed messages on client reconstruction via ProtocolError.fromError()
('MCP error -32042: MCP error -32042: ...')
Fix: store the original unprefixed message as ProtocolError.rpcMessage and
use it in the protocol serialization path. Error.message retains the prefix
for developer-facing console/stack output.
Adds integration test validating exact wire format for -32042
URLElicitationRequiredError including:
- Clean (unprefixed) error.message on the wire
- Correct error.data.elicitations structure
- Single-prefix on client-side reconstructed Error.message
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
12 tasks
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.
This fix allows the URL Elicitation details to be handled by the Client SDK in the case of a
-32042style error.Adds integration test validating exact wire format for -32042 URLElicitationRequiredError including:
Motivation and Context
URL Elicitations via the -32042 error path can't be processed via the Client SDK.
How Has This Been Tested?
Tested with inspector branch.
Breaking Changes
No
Types of changes
Checklist
Additional context