Skip to content

fix: route datamate tools through local stdio mcp-engine instead of cloud#893

Draft
altimate-harness-bot[bot] wants to merge 8 commits into
mainfrom
fix/datamate-stdio-local-transport
Draft

fix: route datamate tools through local stdio mcp-engine instead of cloud#893
altimate-harness-bot[bot] wants to merge 8 commits into
mainfrom
fix/datamate-stdio-local-transport

Conversation

@altimate-harness-bot
Copy link
Copy Markdown
Contributor

@altimate-harness-bot altimate-harness-bot Bot commented Jun 5, 2026

Problem

DatamateManagerTool.handleAdd() was creating MCP server entries pointing to the cloud MCP server (https://mcpserver.getaltimate.com) because buildMcpConfig() always fell back to DEFAULT_MCP_URL when mcpServerUrl was absent from altimate.json.

The cloud MCP runs in multi-user mode and reads connections from API headers — it has no access to ~/.altimate/connections.json. So any tool call like datamate-remote_jira_get_issue failed with "No connection configured for integration: jira" even when connections were configured locally.

Fix

datamate.tshandleAdd()

Replace buildMcpConfig() (HTTP remote) with a local stdio config:

const mcpConfig = {
  type: "local" as const,
  command: ["datamate", "start-stdio", "--datamate", args.datamate_id],
}

Each spawned datamate start-stdio process:

  • Reads connections.json from ~/.altimate/ directly (local engine, same as VS Code extension)
  • Discovers the right VS Code extension bridge at runtime via cwd-based sidecar matching in ~/.altimate/extension-rpc/
  • Multiple VS Code windows are handled correctly — each window's bridge writes a sidecar with its workspaceFolders; the spawned process matches on process.cwd() (set to project root by StdioClientTransport) and routes to the right bridge automatically

mcp-discover.tsstripSessionEnv()

When persisting a discovered server via mcp_discover, strip ALTIMATE_EXTENSION_RPC from the environment block before writing to disk. The socket path is session-specific (unique to the current extension host process) — hardcoding it would cause future sessions to connect to a dead or wrong bridge. Stripping it forces runtime discovery.

Prerequisites

Requires the global datamate CLI to be on PATH: npm install -g @altimateai/datamate. The VS Code extension already warns users when stdio mode is configured but no global datamate is found.

Related PRs

  • AltimateAI/altimate-mcp-engine#211 — writes mcpServerUrl to altimate.json (interim fix, superseded by this approach)
  • AltimateAI/vscode-altimate-mcp-server#360 — same interim fix for the VS Code extension

Requested by @saravmajestic via harness


Summary by cubic

Route datamate tools through the local MCP engine when available, auto-detecting stdio vs HTTP from .vscode/mcp.json. Sync the datamate server by updatedAt (works for stdio and HTTP), keep other remote MCP URLs up to date, add a live reload endpoint, and refresh tools after reconnects.

  • Bug Fixes

    • datamate.ts: detect transport from .vscode/mcp.json; use local stdio ["datamate", "start-stdio", "--datamate", id], use HTTP url if present, or fall back to cloud; save with enabled: true.
    • Local engine reads ~/.altimate/connections.json and auto-selects the right VS Code bridge via cwd-based sidecars; supports multiple windows.
    • mcp-discover.ts: strip ALTIMATE_EXTENSION_RPC from persisted env to avoid dead/wrong sockets.
    • serve.ts + config.ts: on startup, sync the datamate entry from .vscode/mcp.json by updatedAt (covers stdio + HTTP); other remote MCP entries sync via URL comparison; write updatedAt and add structured logs.
    • server.ts: add POST /altimate/mcp/reload-datamate to re-sync from .vscode/mcp.json and reconnect updated MCP clients without a server restart; add request/decision logs.
    • session/prompt.ts: refresh session MCP tools on MCP.ToolsChanged events and log the refresh.
    • mcp/index.ts: persist enabled/disabled state to config on MCP connect/disconnect so it survives restarts.
  • Migration

    • Ensure the datamate CLI is on PATH: npm install -g @altimateai/datamate.

Written for commit ff6f9d4. Summary will update on new commits.

Review in cubic

…loud

DatamateManagerTool.handleAdd() was creating MCP server entries pointing
to the cloud MCP (https://mcpserver.getaltimate.com) because buildMcpConfig()
fell back to DEFAULT_MCP_URL when mcpServerUrl was not set. The cloud MCP
has no access to connections.json, causing "No connection configured for
integration: jira" even when connections were configured locally.

Replace the HTTP/remote config with a local stdio config:
  { type: "local", command: ["datamate", "start-stdio", "--datamate", id] }

Each spawned process:
- Reads connections.json from ~/.altimate/ directly (local engine)
- Discovers the right VS Code extension bridge via cwd-based sidecar matching
  in ~/.altimate/extension-rpc/, supporting multiple VS Code windows cleanly
  without any shared URL or socket path in the config

Also strip ALTIMATE_EXTENSION_RPC from environment when persisting discovered
servers via mcp_discover — the socket path is session-specific and would
cross-wire spawned processes to wrong bridges on future sessions.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

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
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@altimate-harness-bot
Copy link
Copy Markdown
Contributor Author

E2E Verification — PASSED ✓

Full pipeline tested end-to-end in the sandbox:

Test setup:

  • altimate serve running on port 4097 (bun source, live-reloads PR branch changes)
  • Mock Altimate backend on port 5001 (returns Jira datamate with type: "tool")
  • Mock Jira REST API on port 5001 (serves /rest/api/2/issue/AI-6348)
  • connections.json using type: "server" + jiraBaseUrl: "http://localhost:5001" (avoids need for real credentials)

Results:

✓ Initialized: AltimateMCPStdioServer
✓ Tools: 8 total, 8 Jira tools
   - jira_get_issue, jira_create_issue, jira_get_child_issues,
     jira_add_comment, jira_update_issue_status, jira_get_available_transitions,
     jira_link_issue, jira_get_link_types

→ Calling jira_get_issue(issueIdOrKey: "AI-6348")...

✓ jira_get_issue("AI-6348") SUCCESS!
  key: AI-6348
  summary: feat: Ingest Snowflake TASK_HISTORY / SERVERLESS_TASK_HISTORY / COMPLETE_TASK_GRAPHS...
  status: Done
  assignee: Raghwendra Singh

What was verified:

  1. datamate.ts patch: handleAdd() creates { type: "local", command: ["datamate", "start-stdio", "--datamate", id] } instead of cloud HTTP config
  2. mcp-discover.ts patch: stripSessionEnv() removes ALTIMATE_EXTENSION_RPC before persisting to altimate-code.json — verified environment key absent in written config
  3. Full MCP JSON-RPC stdio handshake: initialize → tools/list (8 tools) → tools/call → real tool response
  4. discoverExternalMcp reads .vscode/mcp.json correctly, transforms stdio entry to { type: "local" }, strips session socket path

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

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