Repository navigation
[AGE-2723] Backport x-tfg-mcp-headers (#1313, #1430) to release-v0.179.6 - #1447
Merged
Merged
Conversation
…723) Co-authored-by: Cursor <cursoragent@cursor.com>
rutvij-menavlikar
requested review from
chiragjn,
debajyoti-truefoundry,
heerambavi1998 and
thesujai
as code owners
November 20, 2026 06:34
rutvij-menavlikar
marked this pull request as draft
November 20, 2026 06:38
Co-authored-by: Cursor <cursoragent@cursor.com>
rutvij-menavlikar
marked this pull request as ready for review
November 20, 2026 08:24
Co-authored-by: Cursor <cursoragent@cursor.com>
rutvij-menavlikar
changed the base branch from
release-v0.179.5
to
release-v0.179.6
November 20, 2026 09:20
chiragjn
approved these changes
Nov 20, 2026
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.
Summary
Backports
x-tfg-mcp-headersper-MCP-server headers (#1313) and theonUnauthorizedhook refactor (#1430) torelease-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.tsdoes not exist on 0.179, so its changes are ported here.ServerPersistence.resolveMcpServerStore/buildResolveMcpServerStoretake the rawx-tfg-mcp-headersstring; TrueFoundry mode parses it withparseTrueFoundryPerServerMcpHeaders, open-source mode returns a per-requestMcpServerWithAuthStorewithparsePerServerMcpHeaders. Standalone persistence usesbuildResolveMcpServerStore({ client: undefined, ... })over an extractedSqliteMcpServerStore;createServerRuntimepasses the raw header through.packages/trueforge-core/src/core/mcp/remoteMcpClient.ts: only exportsisAuthErrorand adds theMcpConnectionError401 branch (main's surroundingmcpConnectOutcomenot pulled in).packages/trueforge/src/apis/turns.ts: no changes; the PR's edits target code absent on 0.179 (withTurnSessionHeader,X_TFG_MCP_HEADERSimport).No extra code from main was pulled in.
How was this tested?
pnpm --filter @truefoundry/trueforge-core typecheckand testtests/core/mcp: pass (42 tests).pnpm --filter @truefoundry/trueforge typecheck: src andtests/dbpass;tests/unit/apis/turns.test.tshas one type error (resolveTurnSkillsStore), pre-existing on cleanrelease-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 cleanrelease-v0.179.5.--max-warnings=0on changed src files and prettier--checkon changed files: pass.Checklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/trueforge_sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
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-headersso callers can supply per-MCP-server upstream headers for a turn. Open-source mode merges each entry over manifest/DCR headers; an entry withAuthorizationuses that credential directly and skips DCR. TrueFoundry mode forwards entries (flat or virtual-MCP nested maps) asx-tfy-mcp-headerson the gateway request instead of mergingAuthorizationlocally.RemoteMCPnow treats upstream 401 via an optionalonUnauthorizedhook 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.beginMcpAuthorizationcentralizes 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.