Skip to content

fix(gateway): preserve structured tool results - #212

Closed
its-mash wants to merge 5 commits into
mainfrom
fix/preserve-structured-content
Closed

fix(gateway): preserve structured tool results#212
its-mash wants to merge 5 commits into
mainfrom
fix/preserve-structured-content

Conversation

@its-mash

Copy link
Copy Markdown
Member

Summary

Preserve structuredContent and protocol-level _meta when forwarding downstream tools/call results through the gateway.

Problem

A downstream server can advertise an outputSchema and correctly return both text content and structuredContent. The gateway previously reduced that response to only content plus isError while routing it, then constructed a new CallToolResult from those two fields.

Strict MCP clients consequently rejected otherwise successful tool calls with an error like:

Tool <qualified-name> has an output schema but did not return structured content

This is not specific to one downstream implementation: it affects any tool that advertises an output schema and returns structured output.

Root cause

The result was narrowed at two gateway boundaries:

  1. RoutingService converted the downstream CallToolResult into a custom ToolCallResult containing only content and is_error.
  2. The MCP handler reconstructed a fresh success/error result from those fields.

Both transformations discarded structured_content; protocol-level meta was discarded for the same reason.

Fix

  • Carry structured_content and meta through ToolCallResult.
  • Centralize conversion to and from CallToolResult so both routing boundaries preserve the same fields.
  • Add a regression test covering text content, structured content, metadata, and the success state across the round trip.

No downstream server changes are required.

Verification

  • cargo +1.88.0 fmt --all -- --check
  • cargo +1.88.0 test -p mcpmux-gateway — 145 passed, 0 failed
  • cargo +1.88.0 build --release -p mcpmux
  • End-to-end checks against output-schema tools confirmed that responses routed through the gateway retain both content and structuredContent and pass client-side output validation.

Scope

The patch is limited to the gateway result-conversion path and one regression test. It does not change downstream servers, tool schemas, permissions, or feature-set routing.

Comment on lines +38 to +53
import {
createSpace,
createFeatureSet,
installServer,
getDefaultSpace,
refreshRegistry,
enableServerV2,
emitEvent,
approveOAuthClient,
seedServerFeatures,
listFeatureSetsBySpace,
listServerFeatures,
listClients,
addFeatureToSet,
grantOAuthClientFeatureSet,
} from '../helpers/tauri-api';
@its-mash

Copy link
Copy Markdown
Member Author

Superseded — the contributor's original PR #206 has been reopened; this duplicate re-authored their work under my name.

@its-mash its-mash closed this Jul 15, 2026
@its-mash
its-mash deleted the fix/preserve-structured-content branch July 15, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants