fix(runtime): support subpaths and preserve target routing in MCP proxy - #627
Open
xsvm wants to merge 1 commit into
Open
fix(runtime): support subpaths and preserve target routing in MCP proxy#627xsvm wants to merge 1 commit into
xsvm wants to merge 1 commit into
Conversation
Fixes an issue where the runtime MCP proxy router strictly matched /mcp/proxy/:serverId without a wildcard, causing requests with subpaths (e.g. /messages, /sse) to fail with 404. Also ensures toUpstreamProxyUrl safely appends the subpath onto the resolved upstream URL instead of truncating it.
|
All contributors on this pull request have signed the CLA. |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
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.
Summary
/mcp/proxy/:serverId/*alongside/mcp/proxy/:serverId).extractMcpProxySubPathwith percent-encoding and path traversal guards (..,\,%25,%2f,%5c, and malformed encoding).toUpstreamProxyUrlto correctly append subpaths to upstream target URLs while normalizing trailing slashes and preserving query parameters.grantparameter stripping.Why
/sse,/messages,/tools/call).toUpstreamProxyUrlunconditionally dropped subpaths even if received.Verification
bun test apps/api/tests/driver-mcp-proxy-route.test.ts(5 pass, 0 fail, 17 expects)bun test apps/api/tests/driver-llm-proxy-route.test.ts(33 pass, 0 fail)bun x tsc -p apps/api/tsconfig.json --noEmit(0 errors)vp fmt --check(100% matched)bun scripts/validate-commit-range.ts upstream/main HEAD(1 commit passed)Impact
Review
apps/api/src/adapters/http/routes/driver-route.tsextractMcpProxySubPathandtoUpstreamProxyUrlinternal/private to align with the existingextractLlmProxySubPathpattern and avoid unnecessary public API surface expansion.Design (UI changes only, otherwise N/A)