fix(mcpproxy): parse JSON content types with parameters - #2306
Open
immanuwell wants to merge 1 commit into
Open
Conversation
Signed-off-by: immanuwell <pchpr.00@list.ru>
immanuwell
force-pushed
the
fix/mcpproxy-json-content-type-params
branch
from
June 30, 2026 18:45
3b3d10e to
1c3b9b3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2306 +/- ##
=======================================
Coverage 84.88% 84.89%
=======================================
Files 144 145 +1
Lines 21255 21263 +8
=======================================
+ Hits 18043 18051 +8
Misses 2132 2132
Partials 1080 1080 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Hritik003
reviewed
Aug 11, 2026
Comment on lines
+13
to
+16
|
|
||
| func hasMediaType(header http.Header, want string) bool { | ||
| got, _, err := mime.ParseMediaType(header.Get("Content-Type")) | ||
| if err == nil { |
Contributor
There was a problem hiding this comment.
nit: Can we add this helper function inside the handler file itself?
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
mcpproxyonly treated the exact headerapplication/jsonas JSON. If a backend returnsapplication/json; charset=utf-8, it kinda falls into the SSE path by mistake. That can skip JSON-RPC decoding, missresources/readURI rewriting, andproxyResponseBodycan panic when no session is present.This parses the media type instead, so JSON responses with params still use the JSON path. Pretty small fix, same behavior for existing bare
application/jsonandtext/event-streamcases.Related Issues/PRs (if applicable)
Related to #2218
Related PR: #2229
Special notes for reviewers (if applicable)
Repro:
Content-Type: application/json; charset=utf-8from an MCP backend with a valid JSON-RPC body.resources/read, or the GET notification path.resources/readstops rewriting downstream URIs, andproxyResponseBodycan panic if no session is present.