Skip to content

Separate MCP clients by resolved request headers - #1749

Open
VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/mcp-client-header-identity
Open

VIOLETee0 wants to merge 1 commit into
CodebuffAI:mainfrom
VIOLETee0:fix/mcp-client-header-identity

Conversation

@VIOLETee0

Copy link
Copy Markdown

Problem / Why

Remote MCP clients are cached by transport, endpoint and query parameters, but request headers are omitted. Connecting to the same endpoint with a different authorization header therefore reuses the first client's transport and cached tool catalog. A local MCP server reproduces the second identity receiving the first identity's tools.

This revisits the stale-header case from closed, unmerged #890, with a regression test and a narrower scope.

Changes

  • Include a SHA-256 digest of the environment-resolved headers in HTTP and SSE client cache identities. The returned ID does not contain plaintext header values.
  • Add one real loopback HTTP MCP regression covering distinct authorization identities and reuse of an unchanged identity.

Verification

Validated locally on Windows with Bun 1.3.14, using isolated test environment settings and fictitious authorization values. The branch is based on main c5e985410d548fbf92803fc4e9d64a9142c926a8; the affected tests, probes, static checks and builds were rerun after updating the base.

  • bun test common/src/mcp/__tests__/client-headers.test.ts: failed before the fix (expected who_beta, received who_alpha), passed after it.
  • bun test common/src/mcp/__tests__/: 47 passed, 0 failed.
  • TypeScript checks for common and sdk: passed.
  • SDK build, Windows Freebuff binary build, binary version and official binary smoke test: passed.
  • A separate real HTTP/SSE probe verified environment-header rotation creates distinct clients and restoring the original value reuses its client.
  • ESLint on both changed files: 0 errors, 5 warnings. The production file has the same three warnings as main; the new test has two resolver-environment warnings. The new test passes Prettier; the production file retains its two pre-existing formatting differences.

Notes / Scope

This changes remote cache identity only. It does not add client disposal, connection eviction, retry or replay behavior, or header-name/order canonicalization. No dependency changes. A fresh frozen-lockfile install, the full monorepo suite, Linux/macOS execution and hosted CI have not been run.

This branch has not been deployed

No deployments
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