fix(mcp-clients): strip __binding recursively from configuration state before JWT embed - #6454
Merged
Merged
Conversation
…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.
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
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.
Source: bug found while auditing
apps/api/src/mcp-clients/outbound/headers.ts(MCP outbound transport robustness focus area).Why:
stripBindingMetadataexists specifically to prevent 431 (header-too-large) errors by stripping the__bindingkey — which embeds full tool schemas — fromconfiguration_statebefore 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__bindingstripping, plus the untouched-passthrough cases.Checked locally:
bun run fmt,cd apps/api && bunx tsc --noEmit(clean),bunx oxlinton 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
__bindingfromconfiguration_statebefore embedding it in the JWT. Previously only top-level object values had__bindingremoved; now arrays and nested objects are covered.__bindingat any depth; preserves existing top-level behavior.stripBindingMetadatato acceptunknown; call site now guards null/undefined.Written for commit 94cc8b3. Summary will update on new commits.