feat: IDE-aware datamate transport, enabled-state persistence, and /mcps command

Merged
AL
5mo ago
+906-34

What this does

Four related improvements shipped together:

1. IDE-aware datamate transport (datamate.ts, datamate-transport.ts)

When handleAdd runs and a datamate entry already exists in any IDE mcp.json (VS Code, Cursor, Copilot, etc.), altimate-code reuses the exact command from that file instead of building a new cloud URL config:

  • No duplicate stdio processes — reuses the process the IDE extension already manages
  • No cloud fallback when connections.json is local — same local engine serves both VS Code and the CLI
  • Single gateway: always uses server name "datamate" in extension mode; per-datamate cloud naming only in standalone/CLI mode

Detection scans **/mcp.json under the project root (readDatamateTransportFromIde). Falls back to cloud config when no IDE entry is found.

2. Fix: discovered servers come up enabled and connected (mcp-discover.ts)

/discover-and-add-mcps was writing enabled: false (the discovery-time safety default) even when the user explicitly chose to add a server. Now:

  • Writes enabled: true + updatedAt (ISO timestamp) when the user confirms adding
  • Calls MCP.connect(name) immediately — /mcps shows connected in the same session without a restart
  • Strips ALTIMATE_EXTENSION_RPC from the environment before persisting (socket path is session-specific)

3. Persist enabled/disabled state across restarts (mcp/index.ts)

MCP.connect() and MCP.disconnect() now call persistMcpEnabled(name, true/false), writing the flag back to whichever config file owns the entry. Enabled/disabled state survives session restarts.

4. /mcps command — list and toggle MCP servers (command/index.ts, session/prompt.ts)

New slash command, handled in the session layer without LLM tokens:

  • /mcps — lists all configured MCP servers with live connection status
  • /mcps enable <name> — connects and persists enabled: true
  • /mcps disable <name> — disconnects and persists enabled: false

5. Live reload on IDE mcp.json change (server/server.ts, serve.ts)

  • POST /altimate/mcp/reload-datamate — triggered by the VS Code extension after writing mcp.json; syncs and reconnects with the fresh entry (reads from disk to bypass the stale in-memory Config singleton)
  • syncDatamateUrlFromVscodeMcp also runs at serve startup to catch changes from a VS Code window restart

Related

Requested by @saravmajestic via harness