Skip to content

mcp: Cursor launches codedb without project root, indexes entire home directory #153

@justrach

Description

@justrach

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

  1. The install script registers codedb with "args": ["mcp"] — no project path
  2. Cursor sets CWD to something broad (home dir or workspace root)
  3. codedb resolves root as . (CWD) and starts indexing everything
  4. root_policy.zig only blocks / and /tmp, not home directories
  5. 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:

  1. Refuse to index directories with >10k files and warn the user
  2. Block known-broad paths ($HOME, /Users, /home) in root_policy
  3. Wait for MCP roots/list from 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Medium priority

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions