Codemogger MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add codemogger -- npx -y codemogger mcp
README.md

Code indexing library for AI coding agents.

codemogger

Code indexing library for AI coding agents. Parses source code with tree-sitter, chunks it into semantic units (functions, structs, classes, impl blocks), embeds them locally, and stores everything in a single SQLite file with vector + full-text search.

No Docker, no server, no API keys. One .db file per codebase.

Why

Coding agents need to understand codebases. They need to find where things are defined, discover how concepts are implemented across files, and navigate unfamiliar code quickly. This requires both keyword search (precise identifier lookup) and semantic search (natural language queries when you don't know the exact names).

As AI coding tools become more composable - agents calling agents, MCP servers plugging into different hosts - this capability needs to exist as a library that runs locally. No external servers, no API keys, no Docker containers. Just a function call that returns results.

codemogger is that library. Embedded SQLite (via Turso) with FTS + vector search in a single .db file.

Install

npm install -g codemogger

Or use npx to run without installing.

Quick start

# Index a project
codemogger index ./my-project

# Search
codemogger search "authentication middleware"

Add to your coding agent's MCP config (Claude Code, OpenCode, etc.):

{
  "mcpServers": {
    "codemogger": {
      "command": "npx",
      "args": ["-y", "codemogger", "mcp"]
    }
  }
}

The MCP server exposes three tools:

  • codemogger_search - semantic and keyword search over indexed code
  • codemogger_index - index a codebase for the first time
  • codemogger_reindex - update the index after modifying files

Add the local db to .gitignore:

# codemogger db
.codemogger/

SDK

codemogger is also usable as a library. The SDK has no model dependency - you provide your own embedding function:

import { CodeIndex } from "codemogger"
import { pipeline } from "@huggingface/transformers"

// Load embedding model (runs locally, no API keys)
const extractor = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", { dtype: "q8" })

const embedder = async (texts: string[]): Promise<number[][]> => {
  const output = await extractor(texts, { pooling: "mean", normalize: true })
  return output.tolist() as number[][]
}

const db = new CodeIndex({
  dbPath: "./my-project.db",
  embedder,
  embeddingModel: "all-MiniLM-L6-v2",
})

await db.index("/path/to/project")

// Semantic: "what does this codebase do?"
const results = await db.search("authentication middleware", { mode: "semantic" })

// Keyword: precise identifier lookup
const results = await db.search("BTreeCursor", { mode: "keyword" })

await db.close()

The MCP server and CLI ship with all-MiniLM-L6-v2 by default.

CLI

# Install globally
npm install -g codemogger

# Index a directory
codemogger index ./my-project

# Search
codemogger search "authentication middleware"

# List indexed codebases
codemogger list

How it works

  1. Scan - walk directory, respect .gitignore, detect language from extension
  2. Chunk - parse each file with tree-sitter (WASM), extract top-level definitions (functions, structs, classes, impl blocks). Items >150 lines are split into sub-items.
  3. Embed - encode each chunk with the provided embedding model (runs locally, no API)
  4. Store - write chunks + embeddings to SQLite with FTS index
  5. Search - vector cosine similarity (semantic) or FTS with weighted fields (keyword)

Incremental: only changed files (by SHA-256 hash) are re-processed on subsequent runs.

Languages

Rust, C, C++, Go, Python, Zig, Java, Scala, JavaScript, TypeScript, TSX, PHP, Ruby.

Benchmarks

Benchmarked on 4 real-world codebases on an Apple M2 (8GB). Each project uses its own isolated database. Embeddings use vector8 (int8 quantized, 395 bytes/chunk vs 1,536 for float32). Embedding model: all-MiniLM-L6-v2 (q8 quantized, local CPU). Search times are p50 over 3 runs.

Performance

Project Language Files Semantic Keyword ripgrep
Turso Rust 748 35 ms 1 ms 25 ms
Bun Zig 9,255 137 ms 2 ms 166 ms
TypeScript TypeScript 39,298 242 ms 4 ms 1,500 ms
Kubernetes Go 16,668 617 ms 12 ms 731 ms

Keyword search is 25x-370x faster than ripgrep and returns precise definitions instead of thousands of file matches.

Indexing is a one-time cost dominated by embedding (~97% of time). Subsequent runs only re-embed changed files.

Search quality: semantic search vs ripgrep

The real advantage isn't speed - it's **finding the

Tools (3)

codemogger_searchPerforms semantic and keyword search over indexed code.
codemogger_indexIndexes a codebase for the first time.
codemogger_reindexUpdates the index after modifying files.

Configuration

claude_desktop_config.json
{"mcpServers": {"codemogger": {"command": "npx", "args": ["-y", "codemogger", "mcp"]}}}

Try it

Index the current project directory so I can search through the codebase.
Search for 'authentication middleware' in the codebase using semantic search.
Find the definition of 'BTreeCursor' using keyword search.
Reindex the project to include my recent changes.

Frequently Asked Questions

What are the key features of Codemogger?

Local code indexing using tree-sitter and SQLite. Supports both semantic (vector) and keyword (FTS) search. No external APIs, Docker, or server infrastructure required. Incremental indexing based on file SHA-256 hashes. Supports multiple languages including Rust, Go, Python, and TypeScript.

What can I use Codemogger for?

Enabling AI coding agents to navigate and understand large, unfamiliar codebases. Performing precise identifier lookups across complex projects. Finding conceptual implementations across multiple files using natural language queries. Maintaining a local, private search index for sensitive code repositories.

How do I install Codemogger?

Install Codemogger by running: npx -y codemogger mcp

What MCP clients work with Codemogger?

Codemogger works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Codemogger docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare