FIX stdio URL bug with proxyMode #2935
Open
+93
−10
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.
Problem
So deploying an MCPServer with
transport: stdioandproxyMode: streamable-http, the status URL shows incorectly returns/sseendpoint instead of/mcpExample
Expected status URL:
Actual status URL:
Root Cause
The bug is in
pkg/transport/url.goThis code is old and it shows that its treating stdio same as sse and ignoring proxyMode
So thinking logically we should assume that stdio always use SSE endpoint but stdio can use it either
proxyMode: sse→/sseendpointproxyMode: streamable-http→/mcpendpoint (default)And the controller at
cmd/thv-operator/controllers/mcpserver_controller.go:395only passesTransport, neverProxyMode:OLD CODE TOO missing proxyMode parameter
Solution
So I Added
proxyModeparameter toGenerateMCPServerURL()function:Logic:
For stdio transport: Use
proxyModeto easily determine endpointproxyMode: "streamable-http"→/mcpproxyMode: "sse"→/sse#nameproxyMode: ""(empty) → defaults to/mcp(matches CRD default)For other transports: JUST Ignore
proxyModeits behaviour doesnt change xDssetransport → always/sse#namestreamable-httptransport → always/mcpType Conversions
Added
string()conversions whereProxyModeis a typed string (was stuck on this one for whole night, was going crazy i just needed to convert ProxyMode string to function call, so proxyMode is defined as type ProxyMode string:Testing
Unit Tests (15/15 passing)
$ go test ./pkg/transport/... -v -run TestGenerateMCPServerURLKey test cases covering the bug:
/mcp/sse#name/mcp/sse#name/mcpAll 15 tests pass including targetURI path handling.
Changes
7 files changed:
pkg/transport/url.go- Added proxyMode parameter and logicpkg/transport/url_test.go- Added comprehensive test coveragecmd/thv-operator/controllers/mcpserver_controller.go- Updated call sitepkg/runner/runner.go- Updated call site with type conversionpkg/workloads/manager.go- Updated call site with type conversionpkg/workloads/types/types.go- Updated call site with empty string defaultpkg/vmcp/workloads/k8s.go- Updated call site with type conversionBuild status:
Impact
This fix ensures stdio transport respects the
proxyModesetting:/sse❌/mcp✅/sse✅/sse✅/sse❌/mcp✅/sse✅/sse✅/mcp✅/mcp✅Soooo since CRD is default for
proxyMode isstreamable-http` bug affects the default stdio configurationFixes #2920