Skip to content

fix(server): keep MCP servers with empty login-shell exports - #45425

Open
StiensWout wants to merge 8 commits into
pingdotgg:mainfrom
StiensWout:wf/find-0186c144f3d505344cd07739
Open

StiensWout wants to merge 8 commits into
pingdotgg:mainfrom
StiensWout:wf/find-0186c144f3d505344cd07739

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

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:

  1. Quit T3 Code if it is open.
  2. 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.
  3. 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.
  4. Start T3 Code from the Dock or the application menu.
  5. Open a project, start a new agent thread, and send a message.
  6. 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.

Proven: the repro fails at the test commit a611539927 and passes on the head 0b941c5b3d, both on main 9534251f46.

Before After
Commit a611539927 0b941c5b3d
Result failed with "expected [ { name: 'docs', …(1) } ] to deeply equal [ { name: 'docs', …(1) }, …(1) ]" passed

Outside view: a person sees it in the running desktop app by following the steps under Reproduction on main.

Tests

  • a611539927 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 9534251f4613a96fdcd962cf537a0b4168065268 passed on head.

Not in this change

  • Startup PATH hydration and Windows environment lookup keep their existing behavior.
  • Process environment precedence and MCP reference fallback rules keep their existing behavior.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Grok 4.7, in Grok
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5 and Grok 4.7

StiensWout and others added 7 commits November 29, 2026 10:39
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
…nmentValues comment

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
…h its delimiter

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…t the fix

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 29, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 0b941c5

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.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • 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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4a42cad and 0b941c5.

Files selected for processing: 4

  • apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
  • apps/server/src/os-jank.ts
  • packages/shared/src/shell.test.ts
  • packages/shared/src/shell.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 29, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

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.

Before After
d0c6ead08c 1afdc81103
Before: empty export incorrectly omitted After: empty export passed through as an empty string

Before output · After output · Reproduction/seed driver · Capture renderer

Not shown:

  • 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.

@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 29, 2026

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

size:M 30-99 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants