RAG MCP Server for document search and retrieval
Project description
RAG MCP 服务器使用指南
什么是 RAG MCP 服务器?
这是一个基于 MCP (Model Context Protocol) 的 RAG (Retrieval-Augmented Generation) 服务器,它允许 AI 助手访问和管理知识库,进行智能问答和文档检索。
功能特性
- 📚 文档管理: 添加、删除、查询文档
- 🔍 智能搜索: 基于语义相似度的文档检索
- 💬 问答系统: 根据知识库内容回答问题
- 🏷️ 元数据支持: 为文档添加分类、标签等元信息
- 📊 统计分析: 查看知识库状态和统计信息
快速开始
1. 启动服务器
# 在后台启动服务器
python rag_server.py
# 或者直接运行(会阻塞终端)
python rag_server.py
2. 配置 MCP 客户端
在支持 MCP 的 AI 客户端(如 Claude Desktop)中,添加以下配置:
{
"mcpServers": {
"rag-server": {
"command": "python",
"args": ["/path/to/your/rag-mcp-server/rag_server.py"],
"env": {
"PYTHONPATH": "/path/to/your/rag-mcp-server"
}
}
}
}
3. 使用示例
启动后,AI 助手就可以使用以下工具:
添加文档
add_document("文档内容", {"category": "技术", "language": "中文"})
搜索文档
search_documents("人工智能")
获取文档
get_document("doc_0")
列出所有文档
list_documents()
删除文档
delete_document("doc_0")
获取服务器信息
get_server_info()
配置选项
服务器支持以下配置:
max_results: 最大搜索结果数量 (默认: 5)similarity_threshold: 相似度阈值 (默认: 0.7)supported_formats: 支持的文档格式enable_logging: 是否启用日志记录
支持的文档格式
- 纯文本
- Markdown
- 结构化数据 (JSON)
故障排除
常见问题
-
服务器无法启动
- 检查 Python 环境
- 确认依赖包已安装
- 查看错误日志
-
MCP 连接失败
- 确认服务器正在运行
- 检查客户端配置路径
- 验证 Python 路径设置
-
文档添加失败
- 检查文档内容格式
- 确认元数据格式正确
- 查看服务器日志
日志查看
服务器运行时会输出详细日志,包括:
- 文档操作状态
- 搜索请求处理
- 错误和警告信息
开发说明
项目结构
rag-mcp-server/
├── rag_server.py # 主服务器文件
├── rag_engine.py # RAG 核心引擎
├── mcp_client_config.json # MCP 客户端配置示例
├── requirements.txt # 依赖包列表
└── README.md # 使用说明
扩展功能
你可以通过修改 rag_engine.py 来:
- 添加新的文档格式支持
- 自定义相似度算法
- 集成外部数据源
- 优化搜索性能
技术支持
如果遇到问题,请:
- 查看服务器日志输出
- 检查配置文件格式
- 确认环境依赖
- 参考错误信息进行排查
注意: 这是一个示例实现,生产环境使用前请进行充分测试和安全评估。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rag_mcp_server_lizhibing-0.1.5.tar.gz.
File metadata
- Download URL: rag_mcp_server_lizhibing-0.1.5.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f36fa1cf2c6450a97286c40f79611461abf11966adeb905d9a568dac16476e6c
|
|
| MD5 |
24c6b7b3d13e2d058faf18d863c7c3f8
|
|
| BLAKE2b-256 |
c774b03938f9c7b5ad28b47c21260ec80542722039c6ba165b7e138c04d5eab5
|
File details
Details for the file rag_mcp_server_lizhibing-0.1.5-py3-none-any.whl.
File metadata
- Download URL: rag_mcp_server_lizhibing-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e365768adcd89d2abf40c8d56b686f64eb4ffc23885d694097b43ad3f8376121
|
|
| MD5 |
78604a3fd44bd92c2da06bc2b656a951
|
|
| BLAKE2b-256 |
6c65cd9ecdc16ec4044f781d884b0e782b7287e398deda6e99b983d6ae1001fc
|