local-rag-mcp

MCP搜索检索

提供方 overlorde

搜索检索 stdio · 本地进程 API Key 社区 / 第三方 Claude
查看接入方式

A Model Context Protocol (MCP) server that provides AI agents with access to local LLMs via Ollama, including a full RAG pipeline for persistent, zero-cost codebase search.

一句话选型结论

按资料字段整理

local-rag-mcp 属于搜索检索类 MCP 服务器,stdio · 本地进程,API Key,可直接接入 Claude,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类搜索检索 传输方式stdio · 本地进程 鉴权API Key 部署方式本地部署
GitHub 星标 1 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

搜索检索
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

Local Deployment Local LLM RAG Python Code Search AI Agent Zero Cost

支持客户端

适用场景

Local DeploymentLocal LLMRAG

安装与配置

stdio · 本地进程 API Key
客户端在本机拉起子进程,数据不出本机
python C:/path/to/ollama-mcp-server/server.py

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
联网搜索取证

让模型查最新资料并给出出处。

资料聚合

把一个主题的网页、文档集中抓回来整理。

情报与竞品检索

按关键词持续检索行业动态和竞品信息。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好API Key对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在搜索检索场景里让模型直接调用外部能力的人。
  • 已经在用 Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
local-rag-mcp当前 未标注 stdio · 本地进程 本地部署 有 2026-02-16
Brave Search 433812ff 2 未标注 未标注 无 2026-05-17
Sequentialthinking 1 SSE · 服务端推送 远程部署 有 2026-05-18
Baidu Netdisk 未标注 未标注 未标注 无 2026-05-17
ragflow 未标注 stdio · 本地进程 本地部署 有 2026-04-11
mindsdb (430e18) 未标注 未标注 未标注 有 2026-05-17

服务器档案

搜索检索
字段来自项目仓库与公开索引,中文说明由本站标注
提供方overlorde上游标注的维护方 overlorde
分类搜索检索本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式API Key远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-02-16上游最后核验时间

详细介绍

8.3 KB
来自项目仓库与上游目录的原文,未做删改

Ollama MCP Server

A Model Context Protocol (MCP) server that gives AI agents access to local LLMs via Ollama — including a full RAG pipeline for persistent, zero-cost codebase search.

Why This Project

AI coding agents like Claude Code search codebases by reading files — each file's contents enters the context window, consuming API tokens. Ask a question about a 50-file project and the agent might read 10-15 files before finding the answer. That's thousands of lines of code flowing through the API, most of it irrelevant.

This MCP server addresses that in two ways:

1. RAG Tools — Reduce Context Window Usage

The standout feature. Instead of reading files one by one, the agent calls rag_query with a natural language question. The search, embedding, and retrieval all happen locally — only the relevant chunks (typically 5 snippets, ~200 lines total) enter the context window. The rest of the codebase never touches the API.

  • rag_index a project once — all file reading, chunking, and embedding runs locally
  • rag_query returns only the relevant code chunks, not entire files
  • Persistent across sessions — index once, query repeatedly without re-reading files
  • Incremental re-indexing — only changed files get reprocessed

This is where the real token savings happen. Targeted retrieval instead of brute-force file reading.

2. Local LLM Tools — Offload Inference Costs

The other 11 tools (ollama_chat, ollama_code_review, ollama_summarize, etc.) offload inference work to your local GPU. These don't reduce context window tokens — if Claude passes text to a local model, that text is already in the context. But they save API inference costs: the local model does the thinking for free instead of the API model spending output tokens on it.

Be honest about what saves what:

Tool Saves context tokens? Saves API inference cost?
rag_query Yes — targeted chunks vs reading many files Yes
rag_index Yes — all processing is local Yes
ollama_web_fetch (with prompt) Yes — raw content processed locally Yes
ollama_summarize No — text already in context Yes (local model does the work)
ollama_code_review No — text already in context Yes (local model does the work)
ollama_chat No Yes (local model does the work)

What Makes This Different

  • RAG as composable MCP tools — Not a standalone chatbot. The retrieval pipeline sits alongside code review, summarization, and embedding tools in one toolbox. The agent adapts its strategy per question rather than following a hardcoded pipeline.
  • Persistent project memory — Each project gets its own .rag/ directory with ChromaDB vector storage. Index once, query across sessions. Re-indexing only processes changed files (content-hash tracking).
  • VRAM-aware model orchestration — Automatic model swapping on constrained GPUs (e.g. 8 GB). Embeddings use mistral, answer generation uses qwen2.5-coder, with clean VRAM handoff.
  • Zero cost, zero data leakage — Everything runs on your machine. No API keys for the local models, no cloud vector DBs.
  • Any MCP client gets it — Not locked to one editor or agent. Anything that speaks MCP can use these tools.

Tools

Core LLM Tools (11)

Tool Description
ollama_chat Chat with auto model routing (code, reasoning, general, fast, summarize)
ollama_code_review Code review with qwen2.5-coder
ollama_code_complete Fill-in-the-middle code completion
ollama_explain_code Structured JSON code explanation
ollama_embed Generate embedding vectors
ollama_similarity_search Rank texts by semantic similarity
ollama_extract_structured Extract data into a JSON schema
ollama_summarize Summarize text with mistral-16k
ollama_list_models List local models with metadata
ollama_model_status Show VRAM usage and loaded models
ollama_web_fetch Fetch URLs and process with local LLM

RAG Tools (4)

Tool Description
rag_index Walk project, chunk code/docs, embed, store in ChromaDB
rag_query Natural language search with LLM-grounded answers
rag_status Show index stats (chunks, files, disk usage, breakdown)
rag_forget Delete a project's RAG index

Architecture```

Your question
-> mistral embeds it (local)
-> ChromaDB finds top-k similar chunks
-> VRAM swap (~5s on 8GB GPU)
-> qwen2.5-coder reads chunks + question
-> generates grounded answer


### Chunking Strategy

- **Python**: AST-based extraction of functions and classes
- **C/C++**: Regex + brace-balancing for functions, structs, enums
- **PDF**: Page-grouped text extraction via PyMuPDF (3 pages/chunk, 1-page overlap)
- **Everything else**: Fixed 50-line chunks with 10-line overlap

### Storage

Each indexed project gets a `.rag/` directory:```
project/
  .rag/
    chroma/          <- ChromaDB persistent vector storage
    index_meta.json  <- stats: files, chunks, timestamp, model info

Model Routing

The server automatically selects the best model for each task:

Context Model Use Case
code qwen2.5-coder:7b Code tasks, completion, review
reasoning qwen3:8b Deep analysis with thinking
general mistral Chat, extraction
fast qwen3-nothink Quick answers
summarize mistral-16k Long text processing
embed mistral Embeddings for RAG
lightweight gemma3:4b Fastest, smallest

VRAM is managed automatically — only one model loaded at a time on constrained GPUs.

Prerequisites

  1. Ollama installed and running: https://ollama.com
  2. Python 3.11+
  3. GPU recommended (works on CPU but slower)

Required Models

Pull these models before first use:```bash
ollama pull mistral
ollama pull qwen2.5-coder:7b
ollama pull qwen3:8b
ollama pull gemma3:4b


Optional (for extended features):```bash
ollama pull qwen3-nothink    # fast mode
ollama pull mistral-16k      # long context summarization

Installation```bash

git clone <this-repo>
cd ollama-mcp-server
pip install -r requirements.txt


### Configure Claude Code

Add to your Claude Code MCP settings (`~/.claude/settings.json` or project `.claude/settings.local.json`):```json
{
  &quot;mcpServers&quot;: {
    &quot;ollama-agent&quot;: {
      &quot;command&quot;: &quot;python&quot;,
      &quot;args&quot;: [&quot;C:/path/to/ollama-mcp-server/server.py&quot;]
    }
  }
}

Then restart Claude Code or run /mcp to connect.

Usage Examples

Index a project```

> Use rag_index to index my project at D:/myproject


The agent will call `rag_index(&quot;D:/myproject&quot;)` and report:```
Indexed 92 files -&gt; 274 new chunks.
Chunk breakdown: python: 150, markdown: 80, json: 44
Storage: D:/myproject/.rag/

Query with natural language```

> How does the authentication middleware work?


The agent calls `rag_query` which:
1. Embeds your question locally
2. Retrieves the most relevant code chunks from ChromaDB
3. Feeds them to qwen2.5-coder for a grounded answer
4. Returns the answer with source file references

### Check index status```
&gt; What&#x27;s the RAG status for D:/myproject?

Returns chunk counts, file counts, disk usage, and language breakdown.

Clean up```

> Forget the RAG index for D:/myproject


Deletes the `.rag/` directory and frees disk space.

## Project Structure```
ollama-mcp-server/
  server.py          &lt;- Entry point: imports modules, runs MCP
  app.py             &lt;- FastMCP instance (shared across modules)
  config.py          &lt;- Constants: model routes, file extensions, limits
  helpers.py         &lt;- Model resolution, VRAM management, formatting
  chunking.py        &lt;- Code/doc chunking (Python AST, C/C++, PDF, generic)
  rag.py             &lt;- ChromaDB client management, embedding, metadata
  tools.py           &lt;- 11 core LLM tools
  tools_rag.py       &lt;- 4 RAG tools
  requirements.txt   &lt;- Python dependencies

Supported File Types

The RAG indexer handles 45+ file extensions including:

Code: .py, .c, .cpp, .h, .js, .ts, .java, .go, .rs, .rb, .swift, .kt, .cs, .php, .zig, .asm

Documents: .md, .txt, .pdf, .html, .xml

Config: .json, .yaml, .toml, .ini, .cfg

Files over 512 KB (text) or 50 MB (PDF) are skipped. Directories like .git, node_modules, __pycache__, build, .venv are automatically excluded.

License

MIT

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
local-rag-mcp 怎么安装?

在客户端按下面的安装命令接入:python C:/path/to/ollama-mcp-server/server.py。装完在客户端配置里引用同一个包或端点。

local-rag-mcp 怎么在 Claude 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

local-rag-mcp 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

local-rag-mcp 需要 API Key 吗?

资料标注需要API Key认证,使用前准备好对应凭据,并按最小权限配置。

local-rag-mcp 支持哪些客户端?

资料标注支持 Claude;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

local-rag-mcp 能提供哪些能力?

资料显示能力标签包括 Local Deployment、Local LLM、RAG、Python、Code Search、AI Agent。具体工具清单以官方文档为准。

local-rag-mcp 需要什么运行环境?

运行时为 python;属于本地进程,需要在本机装好运行环境。

local-rag-mcp 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-02-16。