fix(mcp): normalize root-ish path filters in codegraph_files (#426)#466
Merged
colbymchenry merged 1 commit intoMay 26, 2026
Merged
Conversation
The agent (opencode/Gemini Flash on Windows) called codegraph_files with path="/" and got "No files found matching the criteria.", which pushed it straight back to Read/Glob. Indexed file paths are stored as project-relative POSIX (e.g. "src/foo.py"), and the old startsWith filter matched nothing for any of the root-ish or platform-flavored shapes an agent might guess: "/", ".", "./", "", "\\", leading-slash and leading-./ subpaths, or Windows backslash subpaths. Normalize the filter (strip leading "/", "./", "\", bare "."; convert "\" to "/"; trim trailing "/"), then match by exact equal or "<filter>/" boundary — which also kills a sibling-prefix bleed where filter "src" used to match "src-utils/...". Validated on macOS + Linux (Docker) + Windows (Parallels) with 13 new unit tests plus the existing mcp-input-limits/concurrent-locking suites, and end-to-end through opencode in tmux (Big Pickle/OpenCode Zen): codegraph_files [path=/] now returns the project tree and the agent answers directly instead of falling back to Read. Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Summary
codegraph_filesreturned "No files found" whenever the agent passedpath="/",".","./","","\\", or any leading-slash/.//Windows-backslash subpath — pushing it back to Read/Glob (exact opencode + Gemini Flash regression in have to explicitly ask it to check codegraph, otherwise no results #426)./,./,\, bare.; convert\to/; trim trailing/) and switched matching from rawstartsWithto exact-equal or<filter>/boundary — which also kills a sibling-prefix bleed (srcused to matchsrc-utils/...).Closes #426.
Test plan
npx vitest run __tests__/mcp-files-path-normalization.test.ts— 13/13 (macOS)npm test— 1000 passed / 2 skipped (macOS)node:22-bookwormw/--init): 28/28 across path-normalization + mcp-input-limits + concurrent-lockingtreats path="/" as project rootandnormalizes Windows backslashescodegraph_codegraph_files [path=/]now returns the project tree; agent answers from it without falling back to Read🤖 Generated with Claude Code