Skip to main content

Add your description here

Project description

MCP RAG 工具集

基于模型上下文协议(MCP)的智能知识库系统,提供文档处理、知识问答和向量库管理功能。

支持使用豆包与OpenAI

✨ 主要特性

  • 🧠 智能知识库:基于向量检索的 RAG 系统,支持语义搜索和智能问答
  • 📄 多格式文档处理:支持超过 25 种文档格式,包括 PDF、DOCX、PPTX、XLSX、图片、邮件等
  • 🌐 直观 Web 界面:Bento 风格布局,分类展示所有工具功能
  • 🤖 多模型支持:兼容 OpenAI、豆包、Ollama 等主流 AI 模型
  • 🔍 高级过滤搜索:支持按文件类型、内容结构等条件进行精确检索
  • 📊 统计分析:提供知识库统计、嵌入缓存分析等数据洞察
  • ⚡ 本地化处理:支持本地模型推理,保护数据隐私
  • 🔧 向量库管理:提供缓存清理、数据库优化等维护功能

安装

# 安装工具
uv tool install mcp_rag

# 升级工具
uv tool install mcp_rag --upgrade

# 卸载工具
uv tool uninstall mcp_rag

使用

启动 MCP 服务器

mcp_rag server

启动 Web 界面

mcp_rag web

Web 界面提供直观的 Bento 布局,支持以下工具分类:

  • 📥 添加内容:添加文本和文档到知识库
  • ❓ 智能问答:基于知识库进行问答和检索
  • 📊 数据统计:查看知识库和系统统计信息
  • ⚙️ 向量库管理:优化和维护向量数据库

配置

在项目根目录创建 .env 文件进行配置:

# OpenAI 配置
OPENAI_API_KEY=
OPENAI_API_BASE=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini
OPENAI_TEMPERATURE=0
OPENAI_EMBEDDING_MODEL=text-embedding-3-large

# 豆包 配置
# OPENAI_API_KEY=
# OPENAI_API_BASE=https://ark.cn-beijing.volces.com/api/v3
# OPENAI_MODEL=doubao-1-5-pro-32k-250115
# OPENAI_TEMPERATURE=0
# OPENAI_EMBEDDING_MODEL=doubao-embedding-text-240715

mcp客户端配置(豆包为例)

{
    "mcpServers": {
        "rag": {
            "command": "uv",
            "args": [
                "run",
                "mcp-rag",
                "serve"
            ],
            "env": {
                "PYTHONUNBUFFERED": "1",

                "OPENAI_API_KEY": "key",
                "OPENAI_API_BASE": "https://ark.cn-beijing.volces.com/api/v3",
                "OPENAI_MODEL": "doubao-1-5-pro-32k-250115",
                "OPENAI_TEMPERATURE": "0",

                "OPENAI_EMBEDDING_MODEL": "doubao-embedding-text-240715",
            }
        }
    }
}

可用工具

添加内容

  • learn_text(text, source_name) - 添加文本到知识库
  • learn_document(file_path) - 处理并添加文档到知识库

智能问答

  • ask_rag(query) - 基于知识库回答问题
  • ask_rag_filtered(query, file_type, min_tables, min_titles, processing_method) - 带过滤条件的智能检索

数据统计

  • get_knowledge_base_stats() - 显示知识库统计信息
  • get_embedding_cache_stats() - 显示嵌入缓存统计
  • get_data_paths() - 查看存储路径信息

向量库管理

  • clear_embedding_cache_tool() - 清理嵌入缓存
  • optimize_vector_database() - 优化向量数据库性能
  • get_vector_database_stats() - 显示向量数据库统计
  • reindex_vector_database() - 重新索引向量数据库

支持格式

支持超过 25 种文档格式,包括 PDF、DOCX、PPTX、XLSX、图片、邮件等。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_rag-0.3.8.tar.gz (44.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_rag-0.3.8-py3-none-any.whl (50.6 kB view details)

Uploaded Python 3

File details

Details for the file mcp_rag-0.3.8.tar.gz.

File metadata

  • Download URL: mcp_rag-0.3.8.tar.gz
  • Upload date:
  • Size: 44.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for mcp_rag-0.3.8.tar.gz
Algorithm Hash digest
SHA256 f94ab02fd37f4b37d0ea3f18225421ef66e5e32a1f1288180eca3a7c2dd7ef73
MD5 a9d998e487c19cd56c05a374e4c7d50d
BLAKE2b-256 f178fd902cac62032b6c798c5216c3fa2c09a2a101ba07d13db2d90f2dd680fd

See more details on using hashes here.

File details

Details for the file mcp_rag-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: mcp_rag-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 50.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for mcp_rag-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba0a8cc203b92957585e0c259b0113e050ba96f59169e0c6c706773b6ec2846
MD5 949dfdbb9d75325e200e4404d57e2a62
BLAKE2b-256 9a8b447b31678fb5ae152ebd48aa4c72f3e8cd3fec78f4a21866148108d42bf7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page