RAG MCP Tool
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@RAG MCP Toolsearch for recent API changes in the project documentation"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
RAG MCP Tool
本项目是一个基于 Model Context Protocol (MCP) 的 RAG (检索增强生成) 工具,旨在为本地文件提供智能检索能力。本项目能够扫描指定目录下的文本文件,生成向量索引,并通过 MCP 协议提供检索服务。
功能特性
增量索引: 智能识别文件变更,仅对新增或修改的文件进行重新索引,提高效率。
自动过滤: 自动忽略以
.开头的隐藏目录(如.git,.venv等)。多格式支持: 支持常见的纯文本文件格式(.txt, .md, .json, .py, .js 等)。
MCP 协议支持: 提供标准的 MCP 工具
search_rag和read_raw_file,可轻松集成到 Claude Desktop 等客户端。灵活配置: 支持自定义 LLM 服务地址、模型名称和分块策略。
Related MCP server: directory-indexer
安装
本项目需要使用 Python 3.13 或更高版本。推荐使用 uv 进行包管理和运行。
# 克隆仓库
git clone <repository_url>
cd rag_mcp
# 安装依赖
uv sync配置
在项目根目录下创建 config.yaml 文件,参考以下格式进行配置:
llm:
service_type: "local" # 或 "openai" 等
base_url: "http://localhost:1234/v1" # LLM 服务 API 地址
api_key: "your-api-key" # 如果需要
timeout: 60
model:
name: "text-embedding-qwen3-embedding-4b" # 使用的 Embedding 模型名称
context_window: 4096
temperature: 0.7
processing:
chunk_count: 5 # 文本分块数量使用说明
命令行工具
使用 uv run mcp_rag_tool 运行工具。
1. 建立索引
对指定目录进行索引:
uv run mcp_rag_tool --dir /path/to/your/documentsrag数据会存放在 /path/to/your/documents/.muxue_rag 目录下
2. 启动 MCP 服务器
启动服务器以供 MCP 客户端连接:
uv run mcp_rag_tool --serve也可以指定目录启动MCP服务器:
uv run mcp_rag_tool --dir /path/to/your/documents --serve用这种方式启动,serach_rag工具不会有dir_path参数,所有查询会锁定这个目录下。
注意:
此启动方式只用于锁定
serach_rag工具的查询目录(即屏蔽掉dir_path参数),不会建立rag索引。必须先执行
uv run mcp_rag_tool --dir /path/to/your/documents建立索引,再启动mcp服务器。
3. 其他命令
清理索引: 删除指定目录的 RAG 数据库。
uv run mcp_rag_tool --clean --dir /path/to/your/documents备份索引: 备份 RAG 数据库到指定位置。
uv run mcp_rag_tool --backup --dir /path/to/your/documents --backup-path /path/to/backup查看帮助:
uv run mcp_rag_tool --help
MCP 客户端配置
要将此工具添加到 Claude Desktop,请编辑您的 Claude 配置文件 (macOS 上通常位于 ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"rag-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/rag_mcp",
"run",
"mcp_rag_tool",
"--serve"
],
"env": {
"RAG_MCP_CONFIG": "/path/to/rag_mcp/config.yaml"
}
}
}
}注意:请将 /path/to/rag_mcp 替换为您的实际项目路径。
工具列表
启动服务后,将提供以下工具:
search_rag: 根据关键词在索引文档中搜索相关内容,返回内容的同时会返回改内容所在的原始文件。
read_raw_file: 读取指定文件的原始内容,方便进一步分析。
Available Tools
2 toolsread_raw_fileB
Read raw content of a file. Args: file_path: Absolute path to the file.
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the action ('Read raw content') but doesn't mention permissions required, file size limits, encoding issues, error handling, or what happens with binary vs. text files. This leaves significant behavioral gaps for a file I/O operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise with zero wasted words. It states the purpose in one clear sentence, then provides parameter semantics in a structured format. Every sentence earns its place, and the information is front-loaded appropriately.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (one parameter) and the presence of an output schema (which handles return values), the description covers the basics adequately. However, for a file reading operation with no annotations, it should ideally mention more about behavioral aspects like permissions, encoding, or error cases to be fully complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds meaningful context for the single parameter by specifying 'Absolute path to the file', which clarifies the expected format beyond what the schema provides (schema coverage is 0%). This compensates well for the lack of schema descriptions, though it doesn't elaborate on path validation or OS-specific considerations.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('Read') and resource ('raw content of a file'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from the sibling tool 'search_rag', which appears to serve a different function (search vs. raw reading).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. While 'search_rag' seems different, there's no explicit comparison or context about when raw file reading is appropriate versus searching. No prerequisites or exclusions are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_ragC
Search for keyword in RAG database. Args: keyword: Search query. dir_path: Optional directory to search in. If None, searches all indexed directories.
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | ||
| dir_path | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool searches a RAG database but doesn't describe what 'RAG database' entails, how results are returned, whether it's read-only or has side effects, performance characteristics, or error handling. For a search tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by a brief parameter explanation. There's no wasted text, but the structure could be slightly improved by integrating parameter details more seamlessly rather than a separate 'Args:' section.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has an output schema (which handles return values), the description doesn't need to explain outputs. However, with no annotations, 2 parameters (one optional), and 0% schema coverage, the description provides basic purpose and parameter semantics but lacks behavioral context and usage guidelines, making it minimally adequate but incomplete for effective agent use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining 'keyword' as a 'Search query' and 'dir_path' as an 'Optional directory to search in' with default behavior. This clarifies semantics beyond the bare schema, but it doesn't detail format constraints (e.g., path syntax) or search specifics (e.g., case sensitivity), leaving some gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Search for keyword in RAG database.' This specifies the verb ('Search') and resource ('RAG database'), making it immediately understandable. However, it doesn't explicitly differentiate from its sibling tool 'read_raw_file' (which likely reads files rather than searching indexed content), so it misses the highest score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions the optional 'dir_path' parameter but doesn't explain when to specify it or when other tools might be more appropriate. There's no context about prerequisites, limitations, or comparisons with 'read_raw_file', leaving usage decisions unclear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.0- First observed
read_raw_file - First observed
search_rag
TDQS
Scored across 2 tools
The two tools have completely distinct purposes: one reads raw file content, while the other searches a RAG database. There is no overlap in functionality or ambiguity about when to use each tool.
Both tools use snake_case naming, which is consistent. However, the verb patterns differ slightly: 'read' vs. 'search', which is acceptable but not perfectly uniform. The naming is clear and follows a logical convention.
With only two tools, the server feels severely under-scoped for a RAG (Retrieval-Augmented Generation) system. A typical RAG server would include tools for indexing, updating, deleting, or managing the database, not just reading files and searching. This minimal set limits functionality significantly.
The tool surface is highly incomplete for a RAG domain. There are no tools for indexing documents, updating the database, deleting entries, or managing the RAG system's lifecycle. This forces agents into dead ends for basic operations like adding new data or maintaining the database.
Maintenance
Related MCP Connectors
Ingest, manage, and retrieve documents for RAG-powered AI applications
Securely search and manage workspace context files for AI agents and teams.
Search, fetch (with provenance), scan, and convert AI instruction files for agents.
Search and reason over your Obsidian-style Markdown vault, right from ChatGPT.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables real-time indexing and semantic search of local documents (PDF, Word, text, Markdown, RTF) using vector embeddings and local LLMs. Monitors folders for changes and provides natural language search capabilities through Claude Desktop integration.21MIT
- AlicenseNot gradedqualityCmaintenanceProvides AI assistants with semantic search and read access to local files and directories, enabling knowledge retrieval from indexed content.2117MIT
- FlicenseNot gradedqualityDmaintenanceEnables retrieval-augmented generation by allowing LLMs to search documents in a local folder using vector similarity, supporting multiple file formats.-
- AlicenseAqualityDmaintenanceEnables searching and retrieving documents from a local folder to ground LLM answers in your files.2MIT