Skip to content

fix(mcp-clients): strip __binding recursively from configuration state before JWT embed - #6454

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/strip-binding-metadata-recursive-w4
Aug 24, 2026
Merged

fix(mcp-clients): strip __binding recursively from configuration state before JWT embed#6454
pedrofrxncx merged 1 commit into
mainfrom
fix/strip-binding-metadata-recursive-w4

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Source: bug found while auditing apps/api/src/mcp-clients/outbound/headers.ts (MCP outbound transport robustness focus area).

Why: stripBindingMetadata exists specifically to prevent 431 (header-too-large) errors by stripping the __binding key — which embeds full tool schemas — from configuration_state before it's put in the JWT sent to downstream MCP servers. It only checked one level deep: a top-level state key whose direct object value carried __binding. Since Studio doesn't control a downstream MCP's config schema, a binding field can legitimately live inside an array (a multi-value connection selector) or a nested/grouped object — neither shape got stripped, silently reopening the exact 431 failure the function was written to prevent.

Fix: made the strip recursive over both arrays and nested objects, instead of a single shallow pass over top-level keys. Behavior for the existing shape (top-level object value with __binding) is unchanged — this only widens coverage to shapes it previously missed.

Verify: bun test apps/api/src/mcp-clients/outbound/headers.test.ts — new pure-logic unit test covering top-level, array, and nested-object __binding stripping, plus the untouched-passthrough cases.

Checked locally: bun run fmt, cd apps/api && bunx tsc --noEmit (clean), bunx oxlint on both changed files (0 warnings/errors), and the targeted test above (5 pass). Full CI validates the rest.


Summary by cubic

Prevents 431 header-too-large errors by recursively stripping __binding from configuration_state before embedding it in the JWT. Previously only top-level object values had __binding removed; now arrays and nested objects are covered.

  • Recurses through arrays and nested objects and removes __binding at any depth; preserves existing top-level behavior.
  • Only affects the JWT metadata payload; does not mutate input or stored state.
  • Broadens stripBindingMetadata to accept unknown; call site now guards null/undefined.
  • Adds unit tests covering top-level, array, nested-object stripping, and passthrough cases.

Written for commit 94cc8b3. Summary will update on new commits.

Review in cubic

…e before JWT embed

stripBindingMetadata only checked one level deep — a top-level object value's
own __binding key. A downstream MCP's config schema is arbitrary (Studio
doesn't control it), so a binding field can legitimately sit inside an array
(a multi-value connection selector) or a nested/grouped object, and neither
shape got stripped. That reopens the exact 431 header-too-large failure this
function exists to prevent, since __binding embeds full tool schemas.

Made the strip recursive over both arrays and nested objects.
@pedrofrxncx
pedrofrxncx merged commit 9371a92 into main Aug 24, 2026
33 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/strip-binding-metadata-recursive-w4 branch August 24, 2026 15:48
decocms Bot pushed a commit that referenced this pull request Aug 24, 2026
PR: #6454 fix(mcp-clients): strip __binding recursively from configuration state before JWT embed
Bump type: patch

- decocms (apps/api/package.json): 4.260.5 -> 4.260.6
- @decocms/native (apps/native/package.json): 4.260.5 -> 4.260.6

Deploy-Scope: server
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.

1 participant