Skip to content

fix: carry the IDE entry's env when wiring the datamate stdio MCP server - #1080

Closed
ralphstodomingo wants to merge 1 commit into
mainfrom
fix/AI-8361-datamate-stdio-env
Closed

fix: carry the IDE entry's env when wiring the datamate stdio MCP server#1080
ralphstodomingo wants to merge 1 commit into
mainfrom
fix/AI-8361-datamate-stdio-env

Conversation

@ralphstodomingo

@ralphstodomingo ralphstodomingo commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes a customer-reported bug: a datamate-cli.js editor tab suddenly pops open when launching Altimate Code sessions.

Root cause

On desktop editors the extension writes the datamate stdio entry in .vscode/mcp.json with command = the editor's Electron binary and env: {"ELECTRON_RUN_AS_NODE": "1"}, which makes the binary run as Node. datamate_manager add reused the entry's command + args but dropped the env block — both in the immediate spawn and in the entry persisted to .altimate-code/altimate-code.json. Spawned without the flag, Electron boots the editor GUI and opens datamate-cli.js as a document; the MCP client reports -32000 Connection closed. Because the env-less entry is persisted, every subsequent session launch re-pops the file. The existing healing sync (syncDatamateUrlFromVscodeMcp, which carries env correctly) only ran on altimate serve boot and the reload endpoint — never in the TUI or run, so the entry never self-repaired for terminal users.

Changes

  • readDatamateTransportFromIde returns the IDE entry's env (minus ALTIMATE_EXTENSION_RPC, mirroring the sync path) and updatedAt; handleAdd carries the env into the runtime MCP config and persists it as environment, plus updatedAt on disk so the sync recognizes the entry as current.
  • The sync path's inline env-strip is extracted into a shared extractSpawnEnvironment helper so the two paths stay in lockstep (same strip rule, same string-only filtering).
  • The TUI worker and run now run syncDatamateUrlFromVscodeMcp before the first session, as serve already did — entries already persisted broken in the field self-heal on the next launch. In the worker the sync is awaited before the first in-process request and before Server.listen in external-server mode, matching serve's sync-before-listen ordering.

Verification

E2E in the docker code-server harness against a desktop-shaped mcp.json entry (command = an Electron-contract shim that opens its args as documents unless ELECTRON_RUN_AS_NODE=1), driven through real run sessions:

Scenario Published 0.8.10 This branch
datamate_manager add file pops, -32000 Connection closed, env-less entry persisted no pop, connected as 'datamate', entry persists environment + updatedAt
Plain session launch with the 0.8.10-written (env-less) entry file pops on every launch entry healed before MCP connect, no pop

Before — datamate_manager add pops the file open:

before

After — same broken persisted entry, next session heals it and nothing pops:

after

Unit tests: test/release-validation/mcp-datamate-stdio-env.test.ts covers the env carry (strip rule, omission when empty, back-compat bare shape, non-string filtering) and sync parity. Existing mcp-datamate-893 suite unchanged and green; tsgo --noEmit clean.

Claude Code note: Claude honors the entry's env (verified ✔ Connected via claude mcp list with the same shim) — a Claude-side pop comes from a stale env-less copy in the user's own Claude config, which needs a one-time re-add; no code change applicable there.

🤖 Generated with Claude Code

https://claude.ai/code/session_016wHsBpXPtWQxaiDtHkewTa

@ralphstodomingo ralphstodomingo self-assigned this Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: db08db79-35f9-4adc-9543-e4dc73f4987b

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@ralphstodomingo
ralphstodomingo force-pushed the fix/AI-8361-datamate-stdio-env branch from 85aafe7 to 40ec5c6 Compare August 7, 2026 00:07
…io MCP server

`datamate_manager add` reused the command + args from the IDE's `mcp.json`
`datamate` entry but dropped its `env` block, both in the immediate spawn and
in the entry persisted to `.altimate-code/altimate-code.json`. On desktop
editors the command is the editor's Electron binary and `env` carries
`ELECTRON_RUN_AS_NODE=1` — spawned without it, the editor GUI boots and opens
`datamate-cli.js` as a document, the MCP client reports `-32000 Connection
closed`, and the broken persisted entry re-pops the file on every subsequent
session launch.

- `readDatamateTransportFromIde` now returns the entry's env (minus
  `ALTIMATE_EXTENSION_RPC`, mirroring the sync path) and `updatedAt`;
  `handleAdd` carries the env into the runtime config and persists it as
  `environment`, plus `updatedAt` on disk so the sync recognizes the entry
  as current.
- The sync path's inline env-strip is extracted into the shared
  `extractSpawnEnvironment` helper so both paths stay in lockstep.
- The TUI worker and `run` now run `syncDatamateUrlFromVscodeMcp` before the
  first session (as `serve` already did), so entries already persisted
  without `environment` self-heal on the next launch.
@ralphstodomingo
ralphstodomingo force-pushed the fix/AI-8361-datamate-stdio-env branch from 40ec5c6 to 083e908 Compare August 7, 2026 00:11
@ralphstodomingo
ralphstodomingo deleted the fix/AI-8361-datamate-stdio-env branch August 7, 2026 00:37
@ralphstodomingo ralphstodomingo changed the title fix: [AI-8361] carry the IDE entry's env when wiring the datamate stdio MCP server fix: carry the IDE entry's env when wiring the datamate stdio MCP server Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant