MCP server · RAG · TypeScript

Codebase Copilot

Gives Claude Code, Cursor and Claude Desktop real code search over any repository: syntax-aware chunking, local embeddings, hybrid retrieval — and a measured answer to “is it actually better than naive RAG?”

Recall@5
80% → 88%
Recall@1
44% → 62%
MRR@10
0.60 → 0.73
Query latency
5 ms

Naive windows + dense baseline → AST chunks + hybrid. 50 hand-verified questions over honojs/hono.

Try the retriever

The same engine the MCP tools call.

Retrieval mode

Measured, not assumed

50 questions a new contributor might ask, each mapped by hand to the exact function that answers it. 30 are phrased without any identifier from the target. A result only counts if it is in the right file and overlaps the right lines.

Retrieval quality for each configuration on 50 questions
ConfigurationRecall@1Recall@5MRR@10Latency
Naive 50-line windows + dense (baseline)44%
80%
0.605 ms
Naive windows + hybrid54%
84%
0.675 ms
AST chunks + dense50%
80%
0.645 ms
AST chunks + BM2560%
86%
0.69<1 ms
AST chunks + hybrid (RRF)62%
88%
0.735 ms
AST chunks + hybrid + cross-encoder rerank46%
80%
0.60658 ms

The surprise: a general-domain cross-encoder reranker (ms-marco-MiniLM) lowered Recall@5 from 88% to 80% and cost 658 ms per query. It was trained on web passages, not code, so it ships disabled. Toggle it above to see it reorder results.

How it works

  1. 01

    Parse

    tree-sitter (WASM) splits each file into functions, methods, classes and types — not arbitrary 50-line windows. Class fields holding arrow functions count as methods; runs of tiny type aliases are merged.

  2. 02

    Embed

    bge-small-en-v1.5 runs locally through ONNX Runtime — in the CLI and inside the Vercel function. No embedding API, no key, 10 ms per warm query.

  3. 03

    Retrieve

    Cosine search over a flat Float32 file plus BM25 with a code-aware tokenizer (getCookieValue → get, cookie, value), fused with reciprocal-rank fusion.

  4. 04

    Serve

    One tool registry, two transports: stdio for local repos, Streamable HTTP for this hosted demo. The host model does the reasoning; the server only retrieves.

Connect it to your editor

Hosted demo (searches honojs/hono), Streamable HTTP:

claude mcp add --transport http codebase-copilot https://codebase-copilot-omega.vercel.app/api/mcp

Your own repository, fully local over stdio:

git clone https://github.com/yashharkawat/codebase-copilot && cd codebase-copilot && npm install
npm run cli -- index /path/to/your/repo --id myrepo
claude mcp add codebase-copilot -- npx tsx $PWD/cli/main.ts serve

Security posture