mcp-rag
Enables per-project, traceable access to a RAG knowledge base, with tools for searching and adding knowledge chunks.
README
MCP RAG — MCP Server
A Model Context Protocol server that exposes the MCP RAG knowledge base to MCP-compatible clients (Claude Desktop, IDEs, etc.).
It authenticates to the Express backend with a per-project access token. Each user can hold at most one token per project, and the backend records every tool call in its audit log — so any action taken through this server is always traceable back to the user who generated the token.
Tools
| Tool | Description |
|---|---|
whoami |
Identify the user and project the current token is bound to. |
get_project |
Project details: title, summary, and knowledge-base chunk count. |
search_knowledge |
Semantic search over the project's knowledge base (query, optional limit). |
add_knowledge |
Save text as a new chunk in the project's knowledge base (content). |
create_new_project |
Create a project owned by the token's user (title, optional summary). |
change_project_title |
Rename the token's project (title). Owner/admin only. |
change_project_description |
Edit the token's project description (description). Owner/admin only. |
add_member |
Add a member to the token's project (identifier, optional role). Owner/admin only. |
Authorization & prompt-injection safety: the project-management tools never trust the caller's claimed identity or target. The backend resolves the acting user and project from the API token and enforces owner/admin server-side, so a prompt-injected tool call cannot escalate privileges or act on another project.
Semantic search prerequisites
search_knowledge and add_knowledge use vector embeddings via OpenRouter,
so before they work the acting user must:
- Add their own OpenRouter API key in the web app (Profile → OpenRouter API key). Each user uses their own key; it is encrypted at rest and used only for that user's queries. (If an owner wants to sponsor cost, they hand out a limited OpenRouter key for members to paste as their personal key.)
- Optionally have the project owner/admin pick the embedding model for the
project (Members → Embedding model; default
openai/text-embedding-3-small).
If the user has no key set, these tools return a clear error telling them to add
one. whoami and get_project work without a key.
Setup
npm install
Generate a token from the web app's Access Tokens page, then run the server with it in the environment:
MCP_API_BASE_URL=http://localhost:4000/api \
MCP_API_TOKEN=mcp_xxxxxxxx \
npm start
The server speaks JSON-RPC over stdio.
Client configuration
Add it to your MCP client config, e.g. for Claude Desktop:
{
"mcpServers": {
"mcp-rag": {
"command": "node",
"args": ["/absolute/path/to/mcp/src/index.js"],
"env": {
"MCP_API_BASE_URL": "http://localhost:4000/api",
"MCP_API_TOKEN": "mcp_xxxxxxxx"
}
}
}
}
Packaging as a Claude Desktop extension (.mcpb)
Claude Desktop can install this server as a one-click MCP Bundle (.mcpb)
instead of editing the JSON config by hand. A bundle is a zip of the server
code, its node_modules, and a manifest.json.
1. Install the bundler CLI
npm install -g @anthropic-ai/mcpb
# or run it ad-hoc with: npx @anthropic-ai/mcpb <command>
2. Install production dependencies
The bundle must be self-contained, so node_modules has to be present when you
pack (it is included in the .mcpb, even though git ignores it):
npm install --omit=dev
3. Create a manifest.json
Run the interactive generator and answer the prompts:
mcpb init
Then edit the generated file so the server entry point and user-supplied config (API URL + token) are wired up. A working manifest looks like this:
{
"manifest_version": "0.2",
"name": "mcp-rag",
"display_name": "MCP RAG Knowledge Base",
"version": "1.0.0",
"description": "Per-project, traceable access to the MCP RAG knowledge base.",
"author": { "name": "LXVault" },
"license": "MIT",
"server": {
"type": "node",
"entry_point": "src/index.js",
"mcp_config": {
"command": "node",
"args": ["${__dirname}/src/index.js"],
"env": {
"MCP_API_BASE_URL": "${user_config.api_base_url}",
"MCP_API_TOKEN": "${user_config.api_token}"
}
}
},
"user_config": {
"api_base_url": {
"type": "string",
"title": "API Base URL",
"description": "Base URL of the Express backend, e.g. https://<host>-4000.app.github.dev/api",
"default": "http://localhost:4000/api",
"required": true
},
"api_token": {
"type": "string",
"title": "API Token",
"description": "Per-project token from the web app's Access Tokens page.",
"sensitive": true,
"required": true
}
}
}
${__dirname} resolves to the bundle's install directory, and the
${user_config.*} values are prompted for in Claude Desktop at install time —
so the token is entered in the UI rather than committed anywhere.
4. Pack the bundle
mcpb pack
This produces mcp-rag.mcpb in the repo root (git-ignored). Optionally validate
the manifest first with mcpb validate manifest.json.
5. Install it in Claude Desktop
Settings → Extensions → Install Extension, then select the .mcpb file and
fill in the API Base URL and API Token when prompted.
Environment
| Variable | Default | Description |
|---|---|---|
MCP_API_BASE_URL |
http://localhost:4000/api |
Base URL of the Express backend. |
MCP_API_TOKEN |
(required) | Per-project token from the web app. |
See .env.example.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。