fix: carry the IDE entry's env when wiring the datamate stdio MCP server - #1080
fix: carry the IDE entry's env when wiring the datamate stdio MCP server#1080ralphstodomingo wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
85aafe7 to
40ec5c6
Compare
…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.
40ec5c6 to
083e908
Compare
Fixes a customer-reported bug: a
datamate-cli.jseditor tab suddenly pops open when launching Altimate Code sessions.Root cause
On desktop editors the extension writes the
datamatestdio entry in.vscode/mcp.jsonwithcommand= the editor's Electron binary andenv: {"ELECTRON_RUN_AS_NODE": "1"}, which makes the binary run as Node.datamate_manager addreused the entry's command + args but dropped theenvblock — 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 opensdatamate-cli.jsas 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 onaltimate serveboot and the reload endpoint — never in the TUI orrun, so the entry never self-repaired for terminal users.Changes
readDatamateTransportFromIdereturns the IDE entry's env (minusALTIMATE_EXTENSION_RPC, mirroring the sync path) andupdatedAt;handleAddcarries the env into the runtime MCP config and persists it asenvironment, plusupdatedAton disk so the sync recognizes the entry as current.extractSpawnEnvironmenthelper so the two paths stay in lockstep (same strip rule, same string-only filtering).runnow runsyncDatamateUrlFromVscodeMcpbefore the first session, asservealready 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 beforeServer.listenin external-server mode, matchingserve'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 realrunsessions:datamate_manager add-32000 Connection closed, env-less entry persistedconnected as 'datamate', entry persistsenvironment+updatedAtBefore —
datamate_manager addpops the file open:After — same broken persisted entry, next session heals it and nothing pops:
Unit tests:
test/release-validation/mcp-datamate-stdio-env.test.tscovers the env carry (strip rule, omission when empty, back-compat bare shape, non-string filtering) and sync parity. Existingmcp-datamate-893suite unchanged and green;tsgo --noEmitclean.Claude Code note: Claude honors the entry's
env(verified✔ Connectedviaclaude mcp listwith 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