fix(mcp-bridge): encode stderr notifications as JSON#13549
Open
shreemaan-abhishek wants to merge 1 commit into
Open
fix(mcp-bridge): encode stderr notifications as JSON#13549shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
Build the notifications/stderr message with core.json.encode instead of string concatenation, so subprocess stderr output containing double quotes, backslashes or other JSON special characters no longer breaks the framing of the JSON-RPC notification sent to the client.
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.
Description
The
mcp-bridgeplugin forwards a spawned MCP subprocess's stderr to theclient as a
notifications/stderrJSON-RPC message. The message was builtby concatenating the raw stderr line into a JSON string literal, so any
stderr output containing JSON special characters (double quotes,
backslashes, etc.) produced a malformed JSON-RPC notification and broke the
framing of the message sent to the client.
This change builds the notification with
core.json.encodeinstead, whichproperly escapes the content. A regression test in
t/plugin/mcp-bridge.tfeeds a stderr line containing quotes, a backslash and a
}}sequence andasserts the resulting notification is well-formed JSON that round-trips back
to the original content.
Which issue(s) this PR fixes:
Fixes #
Checklist