Bug: search_code always returns 0 results — rg invoked without explicit path
Repository: DeusData/codebase-memory-mcp
Version: v0.6.0 (April 6, 2026)
Platform: Windows 11 (reproduced; likely platform-agnostic)
Summary
mcp__codebase-memory-mcp__search_code always returns { total: 0, results: [] } regardless of the pattern or project, even on a fully indexed repository with 2,862 nodes.
Steps to Reproduce
- Index a repository with
index_repository (full mode, confirmed 2,862 nodes / 6,678 edges)
- Call
search_code with any pattern — e.g. search_code(project="...", pattern="submitRecords")
- Observe: returns
{ total: 0, results: [], raw_match_count: 0 }
- Confirm the pattern exists in the repo by running
rg "submitRecords" directly in the repo root — matches found immediately
Root Cause
The binary invokes rg (ripgrep) without passing an explicit file path or directory argument. When rg is spawned as a child process without a path and its stdin is not a terminal (i.e. it is piped/spawned programmatically), it attempts to read from stdin rather than scanning the filesystem. Since stdin is empty in this context, rg exits with no matches.
The fix is straightforward: pass the repository root path explicitly as the final argument when invoking rg inside search_code.
Incorrect invocation (current):
rg --json --no-heading <pattern>
Correct invocation:
rg --json --no-heading <pattern> <repo_root_path>
Workaround
As a workaround we replicated the intended behavior in a local Node.js script that reads the SQLite DB directly and passes the repo root path explicitly to rg:
const rgArgs = ['--json', '--no-heading', pattern, repoRoot];
spawnSync('rg', rgArgs, { encoding: 'utf8' });
This produces the expected results — matching lines enriched with their containing function from the graph.
Impact
search_code is completely non-functional in any environment where the MCP server is spawned programmatically (i.e. all normal Claude Code / MCP client usage). The tool appears in documentation and is referenced in agent prompts but silently returns empty results for every query, making it a silent failure with no error surfaced to the user.
Bug:
search_codealways returns 0 results —rginvoked without explicit pathRepository: DeusData/codebase-memory-mcp
Version: v0.6.0 (April 6, 2026)
Platform: Windows 11 (reproduced; likely platform-agnostic)
Summary
mcp__codebase-memory-mcp__search_codealways returns{ total: 0, results: [] }regardless of the pattern or project, even on a fully indexed repository with 2,862 nodes.Steps to Reproduce
index_repository(full mode, confirmed 2,862 nodes / 6,678 edges)search_codewith any pattern — e.g.search_code(project="...", pattern="submitRecords"){ total: 0, results: [], raw_match_count: 0 }rg "submitRecords"directly in the repo root — matches found immediatelyRoot Cause
The binary invokes
rg(ripgrep) without passing an explicit file path or directory argument. Whenrgis spawned as a child process without a path and its stdin is not a terminal (i.e. it is piped/spawned programmatically), it attempts to read from stdin rather than scanning the filesystem. Since stdin is empty in this context,rgexits with no matches.The fix is straightforward: pass the repository root path explicitly as the final argument when invoking
rginsidesearch_code.Incorrect invocation (current):
Correct invocation:
Workaround
As a workaround we replicated the intended behavior in a local Node.js script that reads the SQLite DB directly and passes the repo root path explicitly to
rg:This produces the expected results — matching lines enriched with their containing function from the graph.
Impact
search_codeis completely non-functional in any environment where the MCP server is spawned programmatically (i.e. all normal Claude Code / MCP client usage). The tool appears in documentation and is referenced in agent prompts but silently returns empty results for every query, making it a silent failure with no error surfaced to the user.