diff --git a/src/context_engine/project_commands.py b/src/context_engine/project_commands.py index caf5d94..1ccb397 100644 --- a/src/context_engine/project_commands.py +++ b/src/context_engine/project_commands.py @@ -232,6 +232,12 @@ def remove_preference(project_dir: str, key: str) -> bool: # CCE local cache and per-machine files (".cce/", "CCE local cache (per-machine, not for version control)"), (".claude/settings.local.json", "Claude Code local settings written by cce init"), + # `.mcp.json` carries an absolute path to the `cce` binary (different + # on each contributor's machine) and a project_dir argument that's + # also absolute. Committing it would force every contributor to + # share one path layout, which never holds. `cce init` regenerates + # it on each machine, so gitignoring it is the correct default. + (".mcp.json", ".mcp.json contains absolute paths regenerated by `cce init`"), ] diff --git a/tests/test_project_commands.py b/tests/test_project_commands.py index 55f958f..5752697 100644 --- a/tests/test_project_commands.py +++ b/tests/test_project_commands.py @@ -387,6 +387,21 @@ def test_doesnt_duplicate_if_present(self, tmp_path): content = (tmp_path / ".gitignore").read_text() assert content.count(".cce/") == 1 + def test_ignores_mcp_json(self, tmp_path): + """`.mcp.json` contains absolute paths and is regenerated by + `cce init` on each machine — must be in the managed + gitignore block so contributors don't accidentally commit + each other's path layouts.""" + ensure_gitignore(str(tmp_path)) + content = (tmp_path / ".gitignore").read_text() + assert ".mcp.json" in content + + def test_mcp_json_not_duplicated_if_user_already_ignored(self, tmp_path): + (tmp_path / ".gitignore").write_text(".mcp.json\nnode_modules/\n") + ensure_gitignore(str(tmp_path)) + content = (tmp_path / ".gitignore").read_text() + assert content.count(".mcp.json") == 1 + # ── Edge cases ─────────────────────────────────────────────────────────