Bugfix: Why were MCP log_decision() calls from gspace1 routing to ed...

Documentation for Sessions

🐛 Bugfix: Why were MCP log_decision() calls from gspace1 routing to ed...

Date: 2026-02-07
Time: 21:06:38 UTC
Session: editor2-99.7
Agent: storage
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

Why were MCP log_decision() calls from gspace1 routing to editor2 workspace, and how to fix it permanently across all workspace clones?

Task: Fix MCP workspace routing — decisions and docs were going to editor2 instead of gspace1


🎯 Decision Made

Chosen:

Dynamic workspace detection in start-server.sh using $PWD. Three changes: (1) Updated MCP/mcp-gograb-ai/start-server.sh to detect workspace from $PWD (checks package.json + nx.json), falling back to WORKSPACE_ROOT env var, then script dir. (2) Created per-workspace .cursor/mcp.json pointing to the workspace's own start-server.sh. (3) Added .cursor/mcp.json and .cursor/mcp-config.json to .gitignore and removed mcp-config.json from git tracking (git rm --cached).

Options Considered:

  1. Hardcode WORKSPACE_ROOT per workspace in .cursor/mcp.json env block
  2. Make start-server.sh detect workspace dynamically from $PWD
  3. Add workspace parameter to every MCP tool call
  4. Run separate MCP server binaries per workspace

💭 Reasoning

Root cause chain: (1) Global ~/.cursor/mcp.json launched MCP from editor2's start-server.sh. (2) start-server.sh line 15 unconditionally set WORKSPACE_ROOT from SCRIPT_DIR (always editor2). (3) This loaded editor2's .env.local (WORKSPACE_ID=editor2). (4) gspace1 had no per-workspace .cursor/mcp.json override. (5) .cursor/mcp-config.json had hardcoded workspace: editor2. Result: all log_decision/set_session/preflight calls routed to editor2 regardless of which workspace called them. Fix makes detection truly dynamic — $PWD is set by Cursor to the project root when spawning per-project MCP servers. The check for package.json + nx.json ensures we don't accidentally use a random cwd (like ~ or /tmp). Each workspace clone runs its OWN start-server.sh from its OWN .cursor/mcp.json. Both .cursor/mcp.json and .cursor/mcp-config.json are now gitignored (contain machine-specific paths and MongoDB credentials), same treatment as .env.local.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation