Skip to content

fix(install): write cwd to MCP server entry so clients find graph.db - #352

Closed
Devilthelegend wants to merge 2 commits into
tirth8205:mainfrom
Devilthelegend:fix/install-missing-cwd-mcp-json
Closed

fix(install): write cwd to MCP server entry so clients find graph.db#352
Devilthelegend wants to merge 2 commits into
tirth8205:mainfrom
Devilthelegend:fix/install-missing-cwd-mcp-json

Conversation

@Devilthelegend

Copy link
Copy Markdown
Contributor

Summary

Fixes #325

MCP clients (Cursor, Claude Code, Windsurf, etc.) spawn the server process from their own
working directory, not the project root. Without a cwd field, uvx/uv/poetry launches
code-review-graph serve in the wrong directory and cannot locate .code-review-graph/graph.db.

Root Cause

_build_server_entry() built the MCP server entry without a cwd field, so every platform
config written by code-review-graph install was missing it.

Changes

code_review_graph/skills.py

  • Added repo_root: Path parameter to _build_server_entry()
  • Always writes "cwd": str(repo_root) into every platform's server entry
    (Claude Code, Cursor, Windsurf, Kiro, OpenCode, Qwen, Zed, Continue, Codex)
  • Updated call site in install_platform_configs() to pass repo_root

tests/test_skills.py

  • Added assert entry["cwd"] == str(tmp_path) assertions to all platform install tests
  • Fixed test_install_codex_config to dynamically check command/args via
    _detect_serve_command() instead of hardcoded strings

Result

After this fix, .mcp.json will contain:

{
  "mcpServers": {
    "code-review-graph": {
      "command": "uvx",
      "args": ["code-review-graph", "serve"],
      "type": "stdio",
      "cwd": "/my/project"
    }
  }
}

Tests

67/67 tests passing.

@Devilthelegend
Devilthelegend force-pushed the fix/install-missing-cwd-mcp-json branch 2 times, most recently from 3129c37 to dc0ed89 Compare April 20, 2026 09:21
@Devilthelegend
Devilthelegend deleted the fix/install-missing-cwd-mcp-json branch April 20, 2026 09:39
@Devilthelegend
Devilthelegend restored the fix/install-missing-cwd-mcp-json branch April 20, 2026 09:40
@Devilthelegend
Devilthelegend force-pushed the fix/install-missing-cwd-mcp-json branch from dc0ed89 to f35887f Compare April 20, 2026 09:53
Fixes tirth8205#325

MCP clients (Cursor, Claude Code, Windsurf, etc.) spawn the server
process from their own working directory, not the project root.
Without a cwd field, uvx/uv/poetry launches code-review-graph serve
in the wrong directory and cannot locate .code-review-graph/graph.db.

Fix: pass repo_root into _build_server_entry() and write
cwd: str(repo_root) into every platform's server entry.

Also fix test_install_codex_config to dynamically check command/args
via _detect_serve_command() instead of hardcoded strings.
@Devilthelegend
Devilthelegend force-pushed the fix/install-missing-cwd-mcp-json branch from f35887f to cfa68d8 Compare April 20, 2026 11:03
@tirth8205

Copy link
Copy Markdown
Owner

Hi @Devilthelegend — first, an apology: you posted this cwd fix on April 28, and I shipped essentially the same change in ed5e980 on May 7 without crediting your PR. You got there first; the silent overlap is on me.

Main now covers everything in this branch — cwd in _build_server_entry for all platforms (including Codex TOML), the list_tools-based tool filter, shebang detection, module-scope CALLS edges, Julia qualified names, and the duplicate-file cleanup — which is why it conflicts in all six files.

One thing main still lacks: your per-platform entry["cwd"] assertions in test_skills.py. If you open a slim follow-up with just those assertions, rebased on main, I'll gladly take it — it's better regression coverage than what I wrote.

For future PRs: please keep the diff scoped to the title (this one carried ~2,600 lines of unrelated parser/cleanup changes), and run the full suite — the async _restore_tools fixture broke 7 tests in test_main.py. Closing as superseded, with thanks.

@tirth8205 tirth8205 closed this Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install does not write cwd to .mcp.json — MCP server can't find graph database

2 participants