Skip to content

[AGE-2723] Backport x-tfg-mcp-headers (#1313, #1430) to release-v0.179.6 - #1447

Merged
rutvij-menavlikar merged 3 commits into
release-v0.179.6from
rutvij/age-2723_3
Nov 20, 2026
Merged

rutvij-menavlikar merged 3 commits into
release-v0.179.6from
rutvij/age-2723_3

Conversation

@rutvij-menavlikar

@rutvij-menavlikar rutvij-menavlikar commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backports x-tfg-mcp-headers per-MCP-server headers (#1313) and the onUnauthorized hook refactor (#1430) to release-v0.179.6.

Linear: AGE-2723

Changes

Combined net diff of #1313 + #1430, applied as-is except for these 0.179 adaptations:

  • packages/trueforge/src/main.ts: resolvers.ts does not exist on 0.179, so its changes are ported here. ServerPersistence.resolveMcpServerStore / buildResolveMcpServerStore take the raw x-tfg-mcp-headers string; TrueFoundry mode parses it with parseTrueFoundryPerServerMcpHeaders, open-source mode returns a per-request McpServerWithAuthStore with parsePerServerMcpHeaders. Standalone persistence uses buildResolveMcpServerStore({ client: undefined, ... }) over an extracted SqliteMcpServerStore; createServerRuntime passes the raw header through.
  • packages/trueforge-core/src/core/mcp/remoteMcpClient.ts: only exports isAuthError and adds the McpConnectionError 401 branch (main's surrounding mcpConnectOutcome not pulled in).
  • packages/trueforge/src/apis/turns.ts: no changes; the PR's edits target code absent on 0.179 (withTurnSessionHeader, X_TFG_MCP_HEADERS import).
  • Changesets from both PRs merged into one patch changeset.

No extra code from main was pulled in.

How was this tested?

  • pnpm --filter @truefoundry/trueforge-core typecheck and test tests/core/mcp: pass (42 tests).
  • pnpm --filter @truefoundry/trueforge typecheck: src and tests/db pass; tests/unit/apis/turns.test.ts has one type error (resolveTurnSkillsStore), pre-existing on clean release-v0.179.5.
  • pnpm --filter @truefoundry/trueforge test -- tests/unit: 689/690 pass; the one failure (turns › logs session_id and turn_id on SSE abort ...) is pre-existing on clean release-v0.179.5.
  • eslint --max-warnings=0 on changed src files and prettier --check on changed files: pass.

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, python/trueforge_sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

High Risk
Changes MCP authentication and identity forwarding (Authorization bypass, delayed TrueFoundry authorize, 401 recovery), which are security-sensitive paths for tool execution.

Overview
Adds x-tfg-mcp-headers so callers can supply per-MCP-server upstream headers for a turn. Open-source mode merges each entry over manifest/DCR headers; an entry with Authorization uses that credential directly and skips DCR. TrueFoundry mode forwards entries (flat or virtual-MCP nested maps) as x-tfy-mcp-headers on the gateway request instead of merging Authorization locally.

RemoteMCP now treats upstream 401 via an optional onUnauthorized hook on header resolvers: DCR can restart consent, TrueFoundry calls authorize only after 401 when there is no caller entry, and connections reset so the next call reconnects. beginMcpAuthorization centralizes DCR consent URL creation. Request wiring passes the raw header JSON into per-request MCP stores with strict parse validation.

Reviewed by Cursor Bugbot for commit 4a6492a. Bugbot is set up for automated code reviews on this repo. Configure here.

…723)

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rutvij-menavlikar
rutvij-menavlikar marked this pull request as ready for review November 20, 2026 08:24
Co-authored-by: Cursor <cursoragent@cursor.com>
@rutvij-menavlikar
rutvij-menavlikar changed the base branch from release-v0.179.5 to release-v0.179.6 November 20, 2026 09:20
@rutvij-menavlikar rutvij-menavlikar changed the title [AGE-2723] Backport x-tfg-mcp-headers (#1313, #1430) to release-v0.179.5 [AGE-2723] Backport x-tfg-mcp-headers (#1313, #1430) to release-v0.179.6 Nov 20, 2026
@rutvij-menavlikar
rutvij-menavlikar merged commit 4a61a1f into release-v0.179.6 Nov 20, 2026
6 of 11 checks passed
@rutvij-menavlikar
rutvij-menavlikar deleted the rutvij/age-2723_3 branch November 20, 2026 10:24
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