
基于Rust的模型上下文协议(MCP)服务器为AI助手提供了强大的RAG(检索增强生成)能力,帮助理解庞大的代码库。
概览
基于Rust的模型上下文协议(MCP)服务器为AI助手提供了强大的RAG(检索增强生成)能力,帮助理解庞大的代码库。 该MCP服务器使AI助手能够高效搜索和理解大型项目,方法包括:- 创建代码文件的语义嵌入 - 将其存储在本地矢量数据库中 - 提供快速语义搜索功能 - 支持增量更新以提高效率 - : 所有处理均通过 fastembed-rs 本地完成(无需 API 密钥) - : 结合向量相似性与 BM25 关键词匹配,使用互惠秩融合(RRF)以实现最佳效果 - : 使用 Tree-sitter 提取 12 种语言的语义单元(函数、类、方法) - 索引 40+ 种文件类型,包括代码、文档(含 PDF →Markdown 转换)和配置文件 - : 通过智能按需索引搜索提交历史(默认:10 次提交,仅根据需要更深索引) - : 索引和查询多个代码库...
概述(AI 翻译)
基于Rust的模型上下文协议(MCP)服务器为AI助手提供了强大的RAG(检索增强生成)能力,帮助理解庞大的代码库。
概述
该MCP服务器使AI助手能够高效搜索和理解大型项目,方法包括:
- 创建代码文件的语义嵌入
- 将它们存储在本地矢量数据库中
- 提供快速语义搜索功能
- 支持增量更新以提高效率
特色
- 本地优先:所有处理均通过fastembed-rs本地完成(无需API密钥)
- 混合搜索:结合向量相似性与BM25关键词匹配,使用互易秩融合(RRF)实现最佳结果
- 基于AST的分块:使用树置工具提取12种语言的语义单元(函数、类、方法
- 全面的文件支持:索引40+种文件类型,包括代码、文档(含PDF→Markdown转换)和配置文件
- Git 历史搜索:带智能按需索引的搜索提交历史(默认:10次提交,仅根据需要更深索引)
- 多项目支持:通过项目过滤同时索引和查询多个代码库
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Project RAG - MCP Server for Code Understanding
A Rust-based Model Context Protocol (MCP) server that provides AI assistants with powerful RAG (Retrieval-Augmented Generation) capabilities for understanding massive codebases.
Overview
This MCP server enables AI assistants to efficiently search and understand large projects by:
- Creating semantic embeddings of code files
- Storing them in a local vector database
- Providing fast semantic search capabilities
- Supporting incremental updates for efficiency
Features
- Local-First: All processing happens locally using fastembed-rs (no API keys required)
- Hybrid Search: Combines vector similarity with BM25 keyword matching using Reciprocal Rank Fusion (RRF) for optimal results
- AST-Based Chunking: Uses Tree-sitter to extract semantic units (functions, classes, methods) for 12 languages
- Comprehensive File Support: Indexes 40+ file types including code, documentation (with PDF→Markdown conversion), and configuration files
- Git History Search: Search commit history with smart on-demand indexing (default: 10 commits, only indexes deeper as needed)
- Multi-Project Support: Index and query multiple codebases simultaneously with project filtering
- Smart Indexing: Automatically performs full indexing for new codebases or incremental updates for previously indexed ones
- Cross-Process Locking: Filesystem-based locks prevent multiple processes (e.g., multiple Claude Code sessions) from indexing the same codebase simultaneously
- Concurrent Access Protection: Safe lock management prevents index corruption when multiple agents try to index simultaneously
- Stable Embedded Database: LanceDB vector database (default, no external dependencies) with optional Qdrant support
- Language Detection: Automatic detection of 40+ file types (programming languages, documentation formats, and config files)
- Advanced Filtering: Search by file type, language, or path patterns
- Respects .gitignore: Automatically excludes ignored files during indexing
- Never indexes secrets:
.envfiles, private keys, certificates and.aws//.ssh/contents are always excluded - Code Navigation: Find definitions, references, and call graphs (lightweight LSP-like features)
- Adaptive Search Thresholds: Automatically lowers similarity threshold when no results found (0.7 → 0.6 → 0.5 → 0.4 → 0.3)
安装
docker run -p 6333:6333 -p 6334:6334 \配置
{
"mcpServers": {
"project-rag": {
"command": "/absolute/path/to/project-rag/target/release/project-rag",
"env": {
"RUST_LOG": "info"
}
}
}
}