RAG MCP Server

RAG MCP Server

A RAG knowledge base MCP server that adds vector search and reranking capabilities to opencode, supporting multimodal embeddings, multiple knowledge bases, and local storage.

Category
Visit Server

README

RAG MCP Server

一个 RAG 知识库的 MCP server,给 opencode 加上向量检索重排能力

本项目开发目的是为了在 opencode 中使用 rag 文档检索功能,但是使用的是标准的 mcp 格式,理论上在任何支持 mcp 的平台上都能用

设计架构

  • 多模态支持:可以采用 VL 的向量和重排模型
  • 多知识库:可以建多个知识库,分类存放不同类型的文档
  • 本地存储:向量数据和源文件都保存在本地
  • 图片 URL 支持:得益于 openai 统一接口,base64 和 url 都支持且可以混用
┌──────────┐         ┌──────────────────────────────────────────────────┐
│ Opencode │ ──────> │                  RAG MCP Server                  │
│ (Client) │         │                                                  │
└──────────┘         │  ┌────────┐      ┌──────────┐     ┌───────────┐  │
                     │  │ Router │ ───> │ Embedder │ ──> │ Chroma DB │  │
                     │  └────────┘      └──────────┘     └───────────┘  │
                     │      │                │                 │        │
                     │      │                └─────────────────┘        │
                     │      │                         │                 │
                     │      │                    ┌──────────┐           │
                     │      └──────────────────> │  Search  │           │
                     │                           └──────────┘           │
                     │                                │                 │
                     │                           ┌──────────┐           │
                     │                           │  Rerank  │           │
                     │                           └──────────┘           │
                     └────────────────────────────────┼─────────────────┘
                                                      │
                                           ┌─────────────────────┐
                                           │  Matched Docs       │
                                           │  + Context + Answer │
                                           └─────────────────────┘

安装

git clone https://github.com/sglwsjxh/rag-mcp.git
cd rag-mcp
python -m venv venv
.\venv\Scripts\activate
pip install -e .

配置

复制 .env.example.env

cp .env.example .env

填上 API key:

EMBEDDING_BASEURL=https://openrouter.ai/api/v1
EMBEDDING_MODEL=nvidia/llama-nemotron-embed-vl-1b-v2:free
EMBEDDING_API_KEY=sk-or-...
RERANK_BASEURL=https://ai.api.nvidia.com/v1
RERANK_MODEL=nvidia/llama-nemotron-rerank-vl-1b-v2
RERANK_API_KEY=nvapi-...
DATABASE_PATH=./database

推荐使用 OpenRouterNVIDIA 的免费模型,但是任何 openai 兼容的模型都可使用

注册到 opencode

~/.config/opencode/opencode.json 里加这段:

{
  "mcp": {
    "rag": {
      "enabled": true,
      "type": "local",
      "command": [
        "C:/path/to/rag-mcp/venv/Scripts/python.exe",
        "-m",
        "rag_mcp"
      ]
    }
  }
}

重启 opencode,就能直接调这六个工具:

  • list_knowledge_bases - 列出所有知识库
  • add_database - 新建知识库
  • add_file - 往知识库里加文件
  • search - 搜索知识库
  • delete_file - 删除某个文件
  • delete_database - 删除整个知识库

数据目录结构

database/
├── index.json       # 知识库列表和元信息
├── python/          # 单文件夹知识库
│   ├── chroma_db/
│   └── assets/
├── cpp/
│   ├── chroma_db/
│   └── assets/
└── ...

许可证

MIT License

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured