You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(server): keep MCP servers with empty login-shell exports - #45425
On macOS and Linux, a new session could drop an MCP server when its configuration referenced a variable exported with an empty value in the login shell. The server now distinguishes empty exports from unset variables and preserves trailing carriage returns in captured values. The Nushell regression test exercises the production login-shell reader with a real Nushell process.
Commit 0fbd32628b (main), in the running desktop app:
Quit T3 Code if it is open.
In the login profile your macOS or Linux shell reads, export one variable as an empty value and a second variable as a non-empty value.
In ~/.t3/userdata/settings.json, add two enabled command MCP servers: one environment value that names the non-empty variable with no fallback, and one that names the empty variable with no fallback.
Start T3 Code from the Dock or the application menu.
Open a project, start a new agent thread, and send a message.
Open Settings, then Maintenance, then Diagnostics, and refresh the trace view.
Span Logs shows a warning that an MCP server was left out because an environment variable is not set. The server whose setting names the empty export is omitted from the new session. Expected: Both MCP servers are available to the agent. The optional setting is present as an empty value, and Diagnostics does not say that variable is unset.
The cause is at apps/server/src/os-jank.ts:264. Ran cd apps/server && pnpm exec vp test run src/orchestration-v2/ProviderSessionManager.test.ts with the repro test added: it failed in 2 of 2 runs on a clean checkout, with expected [ { name: 'docs', …(1) } ] to deeply equal [ { name: 'docs', …(1) }, …(1) ] in the output.
Evidence
Environment: Linux x64, the repository's own tests.
Macroscope's review found this PR approvable — Explicitly empty login-shell exports now keep configured MCP servers available, while genuinely unset variables still exclude them. The change is limited to environment-value interpretation and preserves existing behavior for other readers.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between 0b941c5 and 1afdc81.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Shell environment capture now distinguishes unset variables from explicitly empty variables. Callers can opt to preserve empty values during extraction, and login-shell variable reading uses that option. Tests cover the extraction behavior and MCP variable expansion.
Changes: Shell variable capture and MCP expansion
Layer / File(s)
Summary
Shell capture and extraction behavior packages/shared/src/shell.ts, packages/shared/src/shell.test.ts
NuShell capture omits unset variables. extractEnvironmentValues can preserve empty values when preserveEmpty is enabled. Tests cover empty, missing, and carriage-return values.
Login-shell and MCP integration apps/server/src/os-jank.ts, apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
Login-shell variable reading enables empty-value preservation. A Linux-only test checks that MCP configuration retains nonempty and empty exports and omits an unset export.
pingdotgg/t3code#45420: Updates end-marker extraction in the same shell-output framing path, including how captured values and CRLF are handled.
Suggested labels:bugfix
Suggested reviewers:juliusmarminge, macroscopeapp
Merge Risk: Minimal · previous review 0b941
MCP servers configured with login-shell variables exported as empty values are now retained at session start instead of being omitted. Variables that are unset are still omitted. Existing behavior is unchanged for startup PATH hydration and Windows lookup. The change is small, tested, and easy to roll back, with no remaining merge risk identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(server): keep MCP servers with empty login-shell exports" matches the main change. The raw summary and objectives show the fix keeps MCP servers whose config references a variable expor…
Description check
The description covers the problem, the change, reproduction steps, and verification with specific test results. It follows the template's Problem, Change, Verification, and attribution structure. The…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(server): keep MCP servers with empty login-shell exports" matches the main change. The raw summary and objectives show the fix keeps MCP servers whose config references a variable exported as empty in the login shell, and the title names that behavior and the affected area.
Full details: Description check
Explanation
The description covers the problem, the change, reproduction steps, and verification with specific test results. It follows the template's Problem, Change, Verification, and attribution structure. The Scope section is weak: it links related issues #35416 and #30963 but does not state clearly that the issue is a bug fix that links to a bug report, and it does not explain why no issue is needed. The Verification section includes a clear before/after test result. Overall the description is mostly complete, so it passes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Linux, real T3 server + OpenCode 2.4.2, fresh database per commit. A scratch bash profile exports an empty value and "hello", leaving a third variable unset. Three enabled stdio MCP probes reference these variables without fallbacks. The same driver adds a git project and starts two new OpenCode threads per side.
Base omitted empty-export and unset-var in both sessions; only set-export launched with "hello". Head launched empty-export with "" and set-export with "hello" in both sessions, while still omitting unset-var.
These images render captured server log excerpts and complete probe launch records; they are not web screenshots.
macOS and other login shells were not exercised; this comparison used Linux and bash.
Full agent-turn completion and MCP tool calls were not asserted; the proof covers session MCP selection and the environment received by launched processes.
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
size:M30-99 changed lines (additions + deletions).takeover:needs-juliusTakeover done; route gate says Julius decidesvouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
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.
On macOS and Linux, a new session could drop an MCP server when its configuration referenced a variable exported with an empty value in the login shell. The server now distinguishes empty exports from unset variables and preserves trailing carriage returns in captured values. The Nushell regression test exercises the production login-shell reader with a real Nushell process.
Related: #35416, #30963
Reproduction on main
Commit 0fbd32628b (main), in the running desktop app:
Span Logs shows a warning that an MCP server was left out because an environment variable is not set. The server whose setting names the empty export is omitted from the new session. Expected: Both MCP servers are available to the agent. The optional setting is present as an empty value, and Diagnostics does not say that variable is unset.
The cause is at
apps/server/src/os-jank.ts:264. Rancd apps/server && pnpm exec vp test run src/orchestration-v2/ProviderSessionManager.test.tswith the repro test added: it failed in 2 of 2 runs on a clean checkout, withexpected [ { name: 'docs', …(1) } ] to deeply equal [ { name: 'docs', …(1) }, …(1) ]in the output.Evidence
Environment: Linux x64, the repository's own tests.
Proven: the repro fails at the test commit a611539927 and passes on the head 0b941c5b3d, both on main 9534251f46.
Outside view: a person sees it in the running desktop app by following the steps under Reproduction on main.
Tests
pnpm exec vp run check:changed 9534251f4613a96fdcd962cf537a0b4168065268passed on head.Not in this change
Who did the work
Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5 and Grok 4.7