Skip to content

feat(transport): complete direct_proxy gateway mode for streamable HTTP#3165

Open
crivetimihai wants to merge 16 commits intomainfrom
feature/meta-propogation
Open

feat(transport): complete direct_proxy gateway mode for streamable HTTP#3165
crivetimihai wants to merge 16 commits intomainfrom
feature/meta-propogation

Conversation

@crivetimihai
Copy link
Copy Markdown
Member

Note: This PR was re-created from #3041 due to repository maintenance. Your code and branch are intact. @madhav165 please verify everything looks good.

✨ Feature / Enhancement PR

🔗 Epic / Issue

Closes #2332


🚀 Summary (1-2 sentences)

Completes direct_proxy gateway mode support for prompts/list, prompts/get, and completion/complete in the streamable HTTP transport, closing the feature gap that existed relative to tools and resources. _meta (carrying progressToken) is forwarded to upstream MCP servers via PaginatedRequestParams where the SDK exposes a params arg, and via raw session.send_request() where it does not.


🧪 Checks

  • make lint passes
  • make test passes

📓 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:

Helper Method _meta forwarding
_proxy_list_prompts_to_gateway prompts/list PaginatedRequestParams(_meta=meta)
_proxy_get_prompt_to_gateway prompts/get session.send_request(GetPromptRequest(...))
_proxy_complete_to_gateway completion/complete session.send_request(CompleteRequest(...))

The list_prompts, get_prompt, and complete handlers each received a direct_proxy path that: extracts X-Context-Forge-Gateway-Id from request headers → looks up the gateway → checks gateway_mode == "direct_proxy" → enforces RBAC via check_gateway_access → delegates to the proxy helper. Falls through to cache mode when no matching direct_proxy gateway is found.

ClientSession.get_prompt() and ClientSession.complete() have no params argument in the MCP Python SDK, so _meta is injected via send_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
Loading

@crivetimihai crivetimihai added this to the Release 1.1.0 milestone Feb 24, 2026
@crivetimihai crivetimihai added enhancement New feature or request mcp-protocol Alignment with MCP protocol or specification SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release labels Feb 24, 2026
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@madhav165 madhav165 force-pushed the feature/meta-propogation branch 4 times, most recently from 4b0bcb2 to ba0a749 Compare March 4, 2026 14:18
@madhav165 madhav165 force-pushed the feature/meta-propogation branch from ba0a749 to 97a6601 Compare March 8, 2026 12:40
madhav165 added 15 commits March 8, 2026 18:39
…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>
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>
@madhav165 madhav165 force-pushed the feature/meta-propogation branch from dc7e036 to fd81611 Compare March 8, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request mcp-protocol Alignment with MCP protocol or specification SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE][API]: Support _meta for all RPC methods

2 participants