envoy icon indicating copy to clipboard operation
envoy copied to clipboard

mcp_json_rest_bridge: synthesize JSON-RPC response for headers-only upstream responses

Open kkukadia opened this issue 5 months ago • 3 comments

When a backend returns a headers-only response (e.g. 204 No Content), the bridge filter was passing it straight through with no body. MCP clients hang or throw because they expect a JSON-RPC response with a matching id.

Closes the TODO(guoyilin42) at line 363 in the filter. Fix injects a synthetic response in encodeHeaders when end_stream=true:

  • tools/call: empty ToolResult, isError derived from status code
  • tools/list: JSON-RPC -32000 error (nothing to return)

Uses the same addEncodedData pattern as grpc_http1_reverse_bridge for trailer-only responses. Three new unit tests covering 204 success, 5xx error, and tools/list 204.

@guoyilin42 quick question before you review; for the tools/call 204 case I went with an empty ToolResult (content: [{type: text, text: ""}], isError: false) since that seemed closest to what the TODO suggested. But wanted to confirm:

  1. Is empty ToolResult the right shape, or would you prefer a JSON-RPC result here?
  2. Should 304 Not Modified be treated the same way as 204?

Happy to adjust before this gets any further review.

kkukadia avatar Jun 19 '26 23:06 kkukadia

/assign @guoyilin42

tyxia avatar Jun 20 '26 17:06 tyxia

/assign @paulhong01

tyxia avatar Jun 22 '26 20:06 tyxia

/wait

botengyao avatar Jun 24 '26 01:06 botengyao