Skip to content

fix(init): robust .mcp.json with absolute path, --db, and cwd#49

Merged
smochan merged 1 commit into
mainfrom
feat/init-robust-mcp-json
May 30, 2026
Merged

fix(init): robust .mcp.json with absolute path, --db, and cwd#49
smochan merged 1 commit into
mainfrom
feat/init-robust-mcp-json

Conversation

@smochan

@smochan smochan commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • codegraph init now writes a .mcp.json that just works regardless of how the MCP client launches the server.
  • Absolute path to codegraph (sibling of running interpreter → shutil.which → bare fallback).
  • Explicit --db .codegraph/graph.db so the server doesn't have to guess.
  • cwd set to repo root.
  • Pre-0.1.2 default entries are migrated forward in place; user-customised entries are left alone.

v0.1.2 backlog item #1. Surfaced when a user added polycodegraph to a FastAPI project — Claude reported needing to hand-fix all three.

Test plan

  • 7 new unit tests in tests/test_cli_mcp_json.py (fresh write, merge, migrate, preserve customised, binary resolution).
  • Full test suite green (603 passed).
  • Manual: fresh codegraph init in a scratch dir produces a .mcp.json whose command is a venv-absolute path, and Claude Code / Cursor launch the server.

🤖 Generated with Claude Code

…d cwd

The 0.1.1 fix wrote .mcp.json but used a bare `codegraph` command with no
--db flag and no cwd. That worked when the MCP client's $PATH and working
directory happened to line up; in practice users had to hand-fix all three
(absolute path → resolved from sys.executable.parent → shutil.which → bare
fallback; --db pointing at .codegraph/graph.db; cwd set to repo root).

Pre-0.1.2 default entries are migrated forward in place. User-customised
entries (different command, extra args, env, cwd) are left untouched.

v0.1.2 backlog item #1.
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +13 / -0 / ~0 nodes, +58 / -0 edges

Findings (0)

No findings.

Triggered by codegraph CI · last run

@smochan smochan merged commit 4eea658 into main May 30, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant