fix(init): robust .mcp.json with absolute path, --db, and cwd#49
Merged
Conversation
…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.
codegraph PR reviewDiff vs main · severity ≤
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codegraph initnow writes a.mcp.jsonthat just works regardless of how the MCP client launches the server.codegraph(sibling of running interpreter →shutil.which→ bare fallback).--db .codegraph/graph.dbso the server doesn't have to guess.cwdset to repo root.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
tests/test_cli_mcp_json.py(fresh write, merge, migrate, preserve customised, binary resolution).codegraph initin a scratch dir produces a.mcp.jsonwhosecommandis a venv-absolute path, and Claude Code / Cursor launch the server.🤖 Generated with Claude Code