-
Notifications
You must be signed in to change notification settings - Fork 36
mcp: Cursor launches codedb without project root, indexes entire home directory #153
Copy link
Copy link
Open
Labels
Description
Problem
When codedb is registered in Cursor as an MCP server with "args": ["mcp"] (no project path), Cursor launches codedb with CWD set to either the home directory or a broad workspace root. codedb then indexes the entire directory tree, consuming gigabytes of memory and taking minutes.
Reproduction
Cursor MCP config (~/.cursor/mcp.json):
{
"mcpServers": {
"codedb": {
"command": "/Users/you/bin/codedb",
"args": ["mcp"]
}
}
}Open Cursor → memory usage spikes to multi-GB, system becomes unresponsive.
Root Cause
- The install script registers codedb with
"args": ["mcp"]— no project path - Cursor sets CWD to something broad (home dir or workspace root)
- codedb resolves root as
.(CWD) and starts indexing everything root_policy.zigonly blocks/and/tmp, not home directories- No file count cap on the initial scan (the 15k trigram cap exists but outline+content indexing continues for all files)
Expected Behavior
codedb should either:
- Refuse to index directories with >10k files and warn the user
- Block known-broad paths (
$HOME,/Users,/home) in root_policy - Wait for MCP
roots/listfrom the client before indexing (Cursor sends workspace roots via MCP protocol)
Possible Fix
// root_policy.zig — block home directory
const home = std.process.getEnvVarOwned(allocator, "HOME") catch null;
if (home) |h| {
if (std.mem.eql(u8, path, h)) return false;
}Or better — use MCP roots/list to get the actual project root instead of relying on CWD.
Environment
- codedb v0.2.53
- Cursor with MCP config
- macOS
Reactions are currently unavailable