
🦀 高性能本地 RAG 服务器,采用 Rust,通过 MCP 与 Claude Desktop 集成。私密搜索 PDF 文档时,使用 Ollama 嵌入——无需外部 API 调用。
概览
这是一个高性能的本地 RAG(检索增强生成)系统,内置于 Rust,通过模型上下文协议(MCP)与 Claude Desktop 集成。可在 Claude 对话中直接搜索和分析您的 PDF 文档,无需将数据发送给外部服务。 本项目演示了如何使用 Rust 构建一个生产准备的 MCP 服务器,具体方法包括: - 使用 poppler 进行文本提取 - 使用本地 Ollama 模型(无外部 API 调用)- 通过文档集合 - 通过 MCP 协议使用 Claude Desktop - 保持所有数据处理本地 模型上下文协议(MCP)是一个标准,允许像Claude这样的AI助手与外部工具和数据源交互。
概述(AI 翻译)
这是一个高性能的本地 RAG(检索增强生成)系统,内置于 Rust,通过模型上下文协议(MCP)与 Claude Desktop 集成。可在 Claude 对话中直接搜索和分析您的 PDF 文档,无需将数据发送给外部服务。
🎯 目的
本项目演示了如何使用 Rust 构建一个生产准备的 MCP 服务器,具体方法包括:
- 本地处理PDF文档,使用poppler进行文本提取
- **使用本地 Ollama 模型生成嵌入(无外部 API 调用)
- 通过文档集合提供语义搜索
- 通过MCP协议与Claude Desktop无缝集成
- 通过保持所有数据处理本地化来维护隐私
🏗️ 什么是MCP?
模型上下文协议(MCP)是一个标准,允许像Claude这样的AI助手与外部工具和数据源交互。MCP使Claude不再局限于其训练数据,而是能够:
- 调用外部工具和函数
- 访问实时数据源
- 与本地应用集成
- 在交互之间保持上下文
🦀 本项目如何使用 Rust MCP SDK
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Rust Local RAG
A high-performance, local RAG (Retrieval-Augmented Generation) system built in Rust that integrates with Claude Desktop via the Model Context Protocol (MCP). Search and analyze your PDF documents directly within Claude conversations without sending data to external services.
🎯 Purpose
This project demonstrates how to build a production-ready MCP server using Rust that:
- Processes PDF documents locally using poppler for text extraction
- Generates embeddings using local Ollama models (no external API calls)
- Provides semantic search through document collections
- Integrates seamlessly with Claude Desktop via MCP protocol
- Maintains privacy by keeping all data processing local
🏗️ What is MCP?
The Model Context Protocol (MCP) is a standard that allows AI assistants like Claude to interact with external tools and data sources. Instead of Claude being limited to its training data, MCP enables it to:
- Call external tools and functions
- Access real-time data sources
- Integrate with local applications
- Maintain context across interactions
🦀 How This Project Uses Rust MCP SDK
This implementation leverages the rmcp crate - the official Rust SDK for MCP - to create a server that exposes RAG capabilities to Claude Desktop.
MCP Architecture in This Project
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ │ (stdin/stdout) │ │
│ Claude Desktop │ ◄─────────────────► │ Rust RAG │
│ │ │ MCP Server │
└─────────────────┘ └──────────────────┘
│
▼
┌──────────────────┐
│ Local RAG Stack │
│ │
│ • PDF Parser │
│ • Ollama │
│ • Vector Store │
│ • Search Engine │
└──────────────────┘
Key MCP Components Used
1. Server Handler Implementation
#[tool(tool_box)]
impl ServerHandler for RagMcpServer {
fn get_info(&self) -> ServerInfo {
// Provides server metadata to Claude
}
}
2. Tool Definitions
Uses rmcp macros to expose RAG functionality as MCP tools:
#[tool(description = "Search through uploaded documents using semantic similarity")]
async fn search_documents(&self, query: String, top_k: Option) -> Result
#[tool(description = "List all uploaded documents")]
async fn list_documents(&self) -> Result
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"rust-local-rag": {
"command": "/Users/yourusername/.cargo/bin/rust-local-rag",
"env": {
"DATA_DIR": "/Users/yourusername/Documents/data",
"DOCUMENTS_DIR": "/Users/yourusername/Documents/rag",
"LOG_DIR": "/tmp/rust-local-rag",
"LOG_LEVEL": "info",
"LOG_MAX_MB": "10"
}
}
}
}