localrag
Provides a search_docs tool for MCP clients to perform local semantic search over indexed files using embeddings, enabling grounded answers from personal notes.
README
localrag
Zero-dependency local semantic search over your own files — plus a tiny MCP server so Claude (or any MCP client) can search them as a tool.
- Nothing leaves your machine. Embeddings come from any OpenAI-compatible endpoint; point it at Ollama, LM Studio, llama.cpp, or vLLM running locally.
- No dependencies. Pure standard library —
urllib,json,math. The index is one JSON file; search is plain cosine similarity. - Two ways in: a
localragCLI, and an MCP server (search_docstool).
Install
pip install localrag
Quick start
Assuming Ollama with an embedding model:
ollama pull nomic-embed-text
localrag build ~/notes ~/docs # index your files (.md/.txt/.rst)
localrag query "what did I decide about the deploy pipeline?"
localrag query "deploy pipeline" --answer # retrieve + let a chat model answer
Output:
=== top 5 for: deploy pipeline ===
[1] (0.812) notes/ops.md
We settled on blue/green with a manual approval gate before cutover...
Use it from Claude / any MCP client (the search_docs tool)
Run the server:
python -m localrag.mcp_server
Register it with an MCP client. For Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"localrag": {
"command": "python",
"args": ["-m", "localrag.mcp_server"],
"env": { "LOCALRAG_INDEX": "/home/you/notes/localrag-index.json" }
}
}
}
Now the model can call search_docs("...") to ground its answers in your notes.
Configuration
All optional — sensible local defaults out of the box.
| Env var | Meaning | Default |
|---|---|---|
LOCALRAG_EMBED_URL |
OpenAI-compatible base URL (incl. /v1) |
http://localhost:11434/v1 |
LOCALRAG_EMBED_MODEL |
embedding model | nomic-embed-text |
LOCALRAG_CHAT_URL |
base URL for --answer |
= LOCALRAG_EMBED_URL |
LOCALRAG_CHAT_MODEL |
chat model for --answer |
qwen3 |
LOCALRAG_API_KEY |
bearer token, if your server needs one | (none) |
LOCALRAG_INDEX |
index file path | ./localrag-index.json |
Using a hosted endpoint instead of local? Point LOCALRAG_EMBED_URL at it and
set LOCALRAG_API_KEY — the same code path works with the OpenAI API.
How it works
- Chunk — files are split on blank lines into ~800-char blocks with a small overlap so context isn't cut mid-thought.
- Embed — each chunk is embedded once and stored with its vector in a JSON index.
- Search — the query is embedded and ranked against every chunk by cosine
similarity. For
--answer, the top chunks become the sole context for a grounded reply.
Small corpora (thousands of chunks) are the sweet spot: no database, no server, just a file you can commit or delete.
License
MIT — see LICENSE.
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.
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.
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.
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.