fix(mcp): serve tools without a root index + monorepo-aware front-load hook (#964) - #966
Merged
Merged
Conversation
… monorepo-aware (#964) The MCP server gated tool availability on whether the server root had a .codegraph/ index, so in a monorepo where only sub-projects are indexed the agent saw zero tools — and couldn't reach an indexed sub-project even by projectPath. A session started before `codegraph init` also never surfaced the tools afterward. The Claude front-load hook had the mirror gap: it only walked UP for an index, so it stayed silent at a monorepo root. MCP server: - Always expose the tool surface; when the root isn't indexed, send a per-project instructions variant (pass projectPath) instead of the "inactive" note. Safety comes from response SHAPE (success-shaped guidance, never isError), not from hiding tools. - Reword the no-default-project guidance to be per-project, not per-session, and sharpen the projectPath schema description. Front-load hook (UserPromptSubmit): - Scan DOWN (bounded depth, workspace-root-gated) for indexed sub-projects and shape the injection by topology: front-load the one the prompt names, nudge about the rest, or list them when ambiguous. Verified: full suite (1703 passed); a live two-package monorepo run confirms the hook front-loads the correct sub-project with no cross-package leakage. The front-load's net speed effect is the existing multi-file-vs-single-file tradeoff, unchanged by this work. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
stupidloud
added a commit
to stupidloud/codegraph
that referenced
this pull request
Jun 25, 2026
Brings in 9 upstream commits incl. monorepo-aware front-load prompt-hook (planFrontload + findIndexedSubprojectRoots, colbymchenry#964/colbymchenry#966), serve-tools- without-root-index, O(K²) import-resolution fix, .gitignore-respecting embedded-repo discovery, and stray-daemon-socket "Transport closed" fix. Fork resolutions: - package.json: keep @stupidloud scope; follow upstream description; version 1.1.1-sl.1 (align upstream major.minor.patch + fork suffix). - codegraph.ts: keep fork's `spawn` import alongside upstream's `planFrontload` import. - CHANGELOG.md: stays removed (fork does not maintain it). - Semantic-search wiring (vectorManager) intact through wireLayers(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Closes #964.
Problem
The MCP server gated tool availability on whether the server root had a
.codegraph/index. In a monorepo where only sub-projects are indexed, the agent saw zero tools and couldn't reach an indexed sub-project even byprojectPath; a session started beforecodegraph initnever surfaced the tools afterward (both reporters hit this — @MaiLunJiye, @iacore). The Claude front-load hook had the mirror gap: it only walked up for an index, so it stayed silent at a monorepo root — exactly where it's most useful.Changes
MCP server
SERVER_INSTRUCTIONS_NO_ROOT_INDEX— "passprojectPath") instead of the "inactive" note. Safety is preserved by response shape (success-shaped guidance, neverisError), not by hiding tools.projectPathschema description.Front-load hook (
UserPromptSubmit)node_modules/.git, capped) for indexed sub-projects, and shape the injection by topology: front-load the sub-project the prompt names, nudge about the rest, or list them byprojectPathwhen ambiguous.Verification
frontload-hook.test.ts, updatedmcp-unindexed.test.ts).claude -p, sonnet/high): the hook front-loads the correct sub-project with zero cross-package leakage (cli prompts never touch preact, and vice-versa).CODEGRAPH_NO_PROMPT_HOOK=1still applies.🤖 Generated with Claude Code