feat(transport): complete direct_proxy gateway mode for streamable HTTP#3165
Open
crivetimihai wants to merge 16 commits intomainfrom
Open
feat(transport): complete direct_proxy gateway mode for streamable HTTP#3165crivetimihai wants to merge 16 commits intomainfrom
crivetimihai wants to merge 16 commits intomainfrom
Conversation
2 tasks
4b0bcb2 to
ba0a749
Compare
ba0a749 to
97a6601
Compare
…ding Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
…warding Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
…_request Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
…equest Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
This reverts commit 7ee8f14.
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
…complete paths Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
…mpletion paths - Fix get_prompt cache path to return GetPromptResult instead of [] on empty/error - Remove duplicate passthrough header loop in _proxy_read_resource_to_gateway - Convert f-string logger calls to percent-style in new proxy helpers and handlers - Fix update_headers_with_passthrough_headers def to remain async (revert accidental sync conversion) - Remove duplicate section header comment in test file - Add missing blank line between test functions (E302) - Add complete gateway-not-found and fallthrough-to-cache test coverage Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
dc7e036 to
fd81611
Compare
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.
✨ Feature / Enhancement PR
🔗 Epic / Issue
Closes #2332
🚀 Summary (1-2 sentences)
Completes
direct_proxygateway mode support forprompts/list,prompts/get, andcompletion/completein the streamable HTTP transport, closing the feature gap that existed relative to tools and resources._meta(carryingprogressToken) is forwarded to upstream MCP servers viaPaginatedRequestParamswhere the SDK exposes aparamsarg, and via rawsession.send_request()where it does not.🧪 Checks
make lintpassesmake testpasses📓 Notes (optional)
What changed
Three new proxy helpers added to
mcpgateway/transports/streamablehttp_transport.py, each following the same pattern already established for tools and resources:_metaforwarding_proxy_list_prompts_to_gatewayprompts/listPaginatedRequestParams(_meta=meta)_proxy_get_prompt_to_gatewayprompts/getsession.send_request(GetPromptRequest(...))_proxy_complete_to_gatewaycompletion/completesession.send_request(CompleteRequest(...))The
list_prompts,get_prompt, andcompletehandlers each received a direct_proxy path that: extractsX-Context-Forge-Gateway-Idfrom request headers → looks up the gateway → checksgateway_mode == "direct_proxy"→ enforces RBAC viacheck_gateway_access→ delegates to the proxy helper. Falls through to cache mode when no matching direct_proxy gateway is found.ClientSession.get_prompt()andClientSession.complete()have noparamsargument in the MCP Python SDK, so_metais injected viasend_request()— the same pattern already used by_proxy_read_resource_to_gateway.Out of scope: SSE, WebSocket, and stdio transports have no direct_proxy infrastructure at all — that is a separate effort.
flowchart TD C[MCP Client] -->|prompts/list, prompts/get, completion/complete| G(MCPGateway\nStreamable HTTP) G -->|gateway_mode == cache| DB[(Database)] G -->|gateway_mode == direct_proxy| U[Upstream MCP Server] U -->|_meta forwarded| U