Fig. 01 · Developer tools / Retrieval

Context
Compiler

The right repository context, in the hands of your AI agent.

My role
Hybrid code retrieval, the Python search endpoint, MCP tracing and result selection
Stack
TypeScript, Python, MCP, pgvector
Status
Live
context-compiler.muhammadtahubkhatri.dev
Context Compiler landing page with the headline “Stop guessing which files to paste into your AI.”
Captured Oct 2026 from the public page.

§ 01

The problem

Coding agents are only as good as what they can see. Give them a whole repository and the useful parts drown; give them too little and they guess.

Context Compiler indexes a repository once, then answers an agent’s natural-language question with a small working set: file paths, excerpts, and the metadata that explains why each piece was selected.

§ 02

System drawing

Solid = per request · Dashed = prepared separately

Request path · query → contextDwg CC-001
  1. 01 · LocalMCP clientcalls search_codebase
  2. 02 · Localstdio bridgeforwards over HTTPS
  3. 03 · Next.js APIResolve accessbearer key → bound repo; invalid keys stop here
  4. 04 · FastAPIEmbed the queryGemini embeddings
  5. 05 · PostgresHybrid retrievalsemantic + lexical, ranked
  6. 06 · OutContext packpaths, excerpts, selection metadata
Index pathGitHub reposcanchunkembedrepository index
Index preparation and query handling are separate paths. The repository is never re-cloned per request.

§ 03

How it came together

Scroll to step through · Mine = my work

  1. Stage 1

    A repository becomes an index

    Repositories are scanned, chunked and embedded ahead of time, so search has something to search.

    + scan → chunk → embed+ store vectors in Postgres (pgvector)
    Index path
  2. Stage 2

    Agents can ask through MCP

    A local stdio bridge exposes search_codebase to any MCP client and forwards calls to the app over HTTPS.

    + src/mcp/server.ts — search_codebase tool+ bearer key → bound repository
    Request path
  3. Stage 3Mine

    Hybrid retrieval

    Semantic and lexical candidates are combined and ranked, and every result carries the reason it was selected.

    - semantic matches only+ semantic + lexical candidates, ranked+ selection metadata on each result
    “Where is access resolved?”
  4. Stage 4

    No cold starts

    The Python service moved to Fly.io so an agent’s first call is as fast as its tenth.

    - Render (sleeps when idle)+ Fly.io, to remove cold starts
    Deploy

§ 04

Decision log

  1. D-01

    Combine semantic and lexical candidates

    Code questions mix ideas (“where is access resolved?”) with exact names (authenticateMcpRequest). Ranking both kinds of match together catches what either misses alone. vector_store.py ↗

  2. D-02

    Index once, query many times

    Scanning, chunking and embedding run separately from search. A query hits an existing index, so a request never waits on a fresh clone. main.py ↗

  3. D-03

    Fail visibly, never fake an answer

    An invalid or revoked key stops at authentication. An empty search returns no matches. Neither outcome is dressed up as a generated answer. route.ts ↗

  4. D-04

    Run the Python service on Fly.io

    The FastAPI backend moved off Render to remove the cold-start delay an agent would otherwise feel on its first call.

§ 05

What I built