feat(codegraph): optional codegraph MCP integration (mirrors engram)#165
Merged
Conversation
Make the codegraph code-graph MCP server usable inside the container when it is installed on the host, mirroring the optional engram integration. The host's ~/.local/bin/codegraph symlink is already visible via the base ~/.local mount, but its target (~/.codegraph, the versioned install dir) was never mounted, so the symlink dangled and `codegraph serve --mcp` could not start. A new docker-compose.codegraph.yml mounts ~/.codegraph so the symlink resolves; it is gated in compose_files() on `codegraph_usable && [ -d ~/.codegraph ]`. The per-repo index <repo>/.codegraph already reaches the container via the project mount, so no separate data mount is needed (unlike engram's DB). The MCP-config filter is generalized from engram-only to a per-tool delete-set: _refresh_container_claude_json() now strips the mcpServers entry of each optional tool not usable in the container (engram and/or codegraph) in one jq del() pass, keeping a cp -a verbatim fast path when nothing must be stripped. Per-tool "not usable" notes are unified behind _note_mcp_unusable(); doctor/status report codegraph. Verification: full bats suite green (1261 ok), shellcheck/shfmt clean. The live MCP startup — codegraph serve --mcp coming up and codegraph_explore answering in a fresh drydock session — is not covered by the unit suite and remains to be confirmed in a live session.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Make the codegraph code-graph MCP server usable inside the container when it is installed on the host, mirroring the optional engram integration (INV-4-style optional feature).
The host's
~/.local/bin/codegraphsymlink is already visible via the base~/.localmount, but its target —~/.codegraph, the versioned install dir — was never mounted, so the symlink dangled andcodegraph serve --mcpcould not start. This change mounts~/.codegraphso the symlink resolves.What changed
lib/compose.shcodegraph_usable()gate (command -v codegraph && host_is_linux);COMPOSE_CODEGRAPHconstant; overlay included incompose_files()gated oncodegraph_usable && [ -d ~/.codegraph ](ccstatusline-style, noexport_compose_envchange)docker-compose.codegraph.yml(new)${HOME}/.codegraph:${HOME}/.codegraph:rwso the symlink resolves. The per-repo index<repo>/.codegraphalready reaches the container viaPROJECT_DIR— no separate data mount (simpler than engram: no shared/isolated, no sentinel)lib/commands.sh_refresh_container_claude_json()generalized from engram-only to a per-tool delete-set: strips themcpServersentry of each optional tool not usable in the container in onejq del()pass, with acp -averbatim fast path when the set is empty. Per-tool notes unified behind_note_mcp_unusable().doctor/statusreport codegraphcodegraph lives at top-level
~/.claude.jsonmcpServers.codegraph(not amcp/*.jsonfile), so the engram-onlyrm -f/rsync-exclude/find-prune belt-and-suspenders are not needed.Invariants
~/.claude*/~/.engram. This change adds a new host-path mount (~/.codegraph). It does not violate INV-2:~/.codegraphis read-mostly install tooling — parallel to~/.local, already host-mountedrw— not Claude/engram session state. None of INV-2's four hazards apply (no~/.claude.jsonclobber, no.credentials.jsonOAuth race, no MCP-filter mutation, no SQLiteengram.db). The overlay header documents this in full.volumes:entry: nocap_add, nosecurity_optchange, noprivileged. Zero new Linux capabilities.rwvsro(deliberate)Mounted
rw, matching the base~/.localmount.rowould be least-privilege but risksEROFSifcodegraph serve --mcpwrites install-dir metadata (update cache / lockfile) at startup, and the security gain is marginal since~/.localis alreadyrw. The overlay header names the residual (new write surface, bounded under threat model A + single-user trust) and recordsroas a documented future hardening once codegraph's serve-time write behavior is confirmed.Verification
shellcheck/shfmt/lint-commitsall clean.drydocksession the overlay activates andcodegraph --version→1.1.2— proving the mount + symlink resolve and the (statically linked) binary executes in the container.Size
~420 changed lines (> 400 budget) →
size:exception. ~206 of those are tests (inseparable under TDD) and ~18 are docs; the actual lib/overlay code is ~159 lines. Splitting a cohesive engram-mirror into chained PRs would harm review focus rather than help.