rag-legacy
Enables Claude Code to semantically search a legacy codebase using natural language queries, returning relevant code chunks via vector search.
README
vite-mf-monorepo-rag
Local RAG system for semantic recall of the vite-mf-monorepo legacy codebase from Claude Code.
Goal
Allow Claude Code, when working in the Next.js project, to find legacy code and patterns by meaning — not by filename. Instead of searching by file name or regex, Claude Code calls recall("how was token refresh handled?") and gets back the most semantically relevant chunks from the legacy codebase.
How it works
1. INDEXING (one-time, then re-run when legacy changes)
pnpm index
→ walks vite-mf-monorepo (349 files)
→ chunks each file into overlapping segments
→ embeds each chunk via nomic-embed-text (Ollama, local)
→ stores chunks + embeddings in MongoDB Atlas (legacy_chunks)
2. RECALL (at query time, triggered by Claude Code)
Claude Code calls the recall() MCP tool with a natural language query
→ query is embedded via nomic-embed-text
→ vector search in MongoDB Atlas finds the top N most similar chunks
→ Claude Code receives file paths + content ranked by semantic similarity
Stack
| Component | Choice |
|---|---|
| Embeddings | nomic-embed-text via Ollama (local, 768 dimensions) |
| Vector store | MongoDB Atlas M0 — rag-cluster / rag / legacy_chunks |
| Vector index | Atlas Vector Search — cosine similarity, filters on filePath, package, app |
| MCP server | Local stdio server exposing recall() to Claude Code |
| Language | TypeScript |
Prerequisites
Ollama
Ollama must be running locally — it handles all embedding generation.
- Download and install from ollama.com
- Pull the embedding model:
ollama pull nomic-embed-text
- Verify:
ollama list
Ollama must be running in the background before indexing or using recall.
Structure
src/
indexer/
index.ts # indexing pipeline entry point
walk.ts # recursive file walker with ignore rules
classify.ts # classifies files as app or package
chunk.ts # splits large files into overlapping chunks
retriever/
recall.ts # embeds query + runs Atlas vector search
mcp/
server.ts # stdio MCP server exposing recall() to Claude Code
Indexed projects
- Legacy (
vite-mf-monorepo) — indexed in MongoDB Atlas - Next (
nextjs-multizone-tmdb) — read live by Claude Code, not indexed
Indexing rules
Indexed: .ts, .tsx, .md — source files and config files
Ignored: node_modules, dist, __mf__temp, .netlify, scripts/, *.test.ts, *.spec.ts, *.d.ts, *.css, *.json, *.sh, .env*, vitest.config.ts, vitest.setup.ts
Setup
pnpm install
cp .env.example .env # fill in MONGODB_URI and LEGACY_PATH
Environment variables
| Variable | Description |
|---|---|
MONGODB_URI |
MongoDB Atlas connection string |
LEGACY_PATH |
Absolute path to the vite-mf-monorepo root |
MCP server setup (nextjs-multizone-tmdb)
The MCP server must be registered in the Next.js project so Claude Code can call recall().
Create .mcp.json at the root of nextjs-multizone-tmdb:
{
"mcpServers": {
"rag-legacy": {
"type": "stdio",
"command": "pnpm",
"args": ["--prefix", "/absolute/path/to/vite-mf-monorepo-rag", "run", "mcp"],
"env": {
"MONGODB_URI": "your_mongodb_uri",
"LEGACY_PATH": "/absolute/path/to/vite-mf-monorepo"
}
}
}
}
Then in Claude Code, run /mcp and accept the server when prompted.
Scripts
pnpm index # run the full legacy indexing pipeline
pnpm mcp # start the MCP server (Claude Code does this automatically)
pnpm build # compile TypeScript
pnpm lint # ESLint
pnpm type-check # type check without compilation
Re-indexing
Run pnpm index whenever the legacy codebase changes. The pipeline clears legacy_chunks and re-indexes everything from scratch.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.