Token导航 LogoToken导航TokenDH.com
Agentic Rag MCP logo
搜索检索stdio官方级别未说明来源级核验

Agentic Rag MCP

MCP Server

一个通过模型上下文协议(MCP)提供智能代码检索与生成能力的服务器,支持代码库索引、语义搜索和智能问答。

工具数

3

提示词数

0

GitHub Stars

2

资源数

0
代码索引PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

aibozo

提供方

aibozo

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python3 -m venv venv

详细介绍

代理RAG MCP服务器

一种智能代码库处理服务器,通过模型上下文协议(MCP)提供代理RAG(检索增强生成)功能。

特性

  • 智能代码索引:自动分块和嵌入代码库以进行语义搜索
  • 代理检索:确保全面上下文的自我批评检索循环
  • 多模型架构:使用GPT-4o进行检索,使用Claude 3进行规划
  • 实时更新:文件系统监视自动重新索引
  • 成本控制:内置遥测和预算管理

快速安装

1.克隆和安装

# Clone the repository
git clone https://github.com/aibozo/agenticrag-mcp.git
cd agenticrag-mcp

# Run the installation script
./install.sh

安装脚本将:

  • 检查Python版本(需要3.8+)
  • 创建虚拟环境
  • 安装所有依赖项
  • 提示输入API密钥
  • 创建必要的目录
  • 生成Claude配置

2.添加到克劳德

安装后,将AgentRAG添加到Claude:

Windows(克劳德桌面):

  1. 打开 %APPDATA%\Claude\claude_desktop_config.json
  2. 从添加配置 claude_config_snippet.json

macOS/Linux(克劳德桌面版):

  1. 打开 ~/.config/claude/claude_desktop_config.json
  2. 从添加配置 claude_config_snippet.json

3.重启克劳德

重新启动Claude以加载新的MCP服务器。

手动安装

如果您更喜欢手动安装:

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Copy and configure environment
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

# Add to Claude Desktop
claude mcp add agenticrag python3 /path/to/agenticrag-mcp/mcp_launcher.py

用法

安装后,您可以在Claude中使用这些工具:

初始化存储库

Please index the repository at /path/to/my/project as "myproject"

搜索您的代码

Search myproject for "how does authentication work?"

获取存储库统计信息

Show me the stats for myproject

对话示例

You: Can you index my FastAPI project at ~/projects/api?

Claude: I'll index your FastAPI project for you.
        [Calls init_repo tool]
        ✓ Successfully indexed repository 'api'
        - Total files: 47
        - Total chunks: 312
        - Total tokens: 52,841
        - Duration: 4.32 seconds

You: How does the authentication middleware work?

Claude: Let me search for information about the authentication middleware.
        [Calls search_repo tool]
        Based on my search, the authentication middleware in your FastAPI project:
        
        1. JWT Token Validation (auth/middleware.py, lines 15-45):
           - Validates Bearer tokens on protected routes
           - Extracts user claims from JWT payload
           - Returns 401 for invalid/expired tokens
        
        2. User Context (auth/middleware.py, lines 50-72):
           - Adds user object to request state
           - Enables access via request.state.user
        
        The middleware is registered in main.py on line 23.

配置

所需的环境变量

# .env file
OPENAI_API_KEY=sk-...        # Required for embeddings and GPT-4
ANTHROPIC_API_KEY=sk-ant-... # Optional, for Claude models

可选配置

# Vector Database
CHROMA_PERSIST_DIRECTORY=./chroma_db

# Logging
LOG_LEVEL=INFO
LOG_FILE=./logs/agenticrag.log

# Models
DEFAULT_EMBEDDING_MODEL=text-embedding-3-large
DEFAULT_LLM_MODEL=gpt-4o

建筑

agenticrag-mcp/
├── src/
│   ├── agents/          # Agentic RAG implementation
│   │   ├── base.py      # Base agent class
│   │   ├── retriever.py # Self-evaluating retriever
│   │   ├── compressor.py # Result compression
│   │   └── workflow.py  # LangGraph orchestration
│   ├── indexing/        # Code indexing pipeline
│   │   ├── chunker.py   # Semantic code chunking
│   │   ├── embedder.py  # OpenAI embeddings
│   │   └── indexer.py   # Repository indexer
│   ├── storage/         # Vector storage
│   │   └── vector_store.py # ChromaDB interface
│   └── mcp_server.py    # MCP server implementation
├── mcp_launcher.py      # MCP entry point
├── install.sh           # Installation script
└── requirements.txt     # Python dependencies

运作原理

  1. 索引:系统会根据语言边界对代码进行分块,并创建嵌入
  2. 检索:搜索时,AI代理会生成优化的查询并检索相关块
  3. 自我评估:代理评估它是否有足够的上下文并可以执行其他搜索
  4. 压缩:对结果进行智能总结,以提供清晰、可操作的答案

故障排除

“没有名为'chromadb'的模块”

激活虚拟环境:

source venv/bin/activate

“找不到OpenAI API密钥”

确保你的 .env 文件包含:

OPENAI_API_KEY=your-key-here

“在Claude中找不到MCP服务器”

  1. 确保您已将配置添加到Claude的配置文件中
  2. 完全重新启动克劳德桌面
  3. 检查登录 ./logs/agenticrag.log

搜索未返回任何结果

确保您首先使用init_repo工具对存储库进行了索引。

发展

运行测试

source venv/bin/activate
python -m pytest tests/

局部测试

# Test indexing
python test_indexing.py

# Test agentic RAG
python test_agentic_rag.py

贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

MIT许可证-请参阅 许可证 文件以获取详细信息。

致谢

如果您更喜欢手动安装:

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Copy and configure environment
cp .env.example .env
# Edit .env with your API keys

用法

安装后,您可以在Claude中使用这些工具:

为存储库建立索引

Use the init_repo tool to index a codebase:
- path: /path/to/your/project
- repo_name: my-project

搜索代码

Use the search_repo tool to find relevant code:
- query: "How does the authentication system work?"
- repo_name: my-project

获取统计信息

Use the get_repo_stats tool to see indexing statistics:
- repo_name: my-project

对话示例

User: Index my Python project at /home/user/myproject

Claude: I'll index your Python project for semantic search.
[Uses init_repo tool with path="/home/user/myproject" and repo_name="myproject"]

User: Find all the database connection code

Claude: I'll search for database connection code in your project.
[Uses search_repo tool with query="database connection" and repo_name="myproject"]
[Returns relevant code snippets with file paths and explanations]

配置

服务器可以通过中的环境变量进行配置 .env:

# API Keys (required)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

# Optional configurations
CHUNK_SIZE_TOKENS=1280        # Size of code chunks
MAX_FILE_SIZE_MB=2           # Maximum file size to index
DAILY_BUDGET_USD=100         # Cost control limit

故障排除

未找到模块

  • 确保虚拟环境已激活: source venv/bin/activate
  • 检查安装: pip list | grep agenticrag

API密钥错误

  • 验证密钥 .env 文件
  • 确保按键周围没有多余的空格或引号
  • 检查所需模型的关键权限

克劳德找不到工具

  • 验证配置路径是绝对的,而不是相对的
  • 查看克劳德日志:帮助→ 显示日志
  • 确保配置中存在MCP服务器部分

服务器无法启动

  • 检查Python版本: python3 --version (需要3.8+)
  • 验证Redis是否正在运行: redis-cli ping
  • 检查端口可用性: lsof -i:8000

性能问题

  • 调整 CHUNK_SIZE_TOKENS 为您的代码库
  • 增加 EMBEDDING_BATCH_SIZE 更快的索引
  • 监控成本 get_repo_stats 工具

发展

运行测试

# Activate virtual environment
source venv/bin/activate

# Run all tests
pytest

# Run with coverage
pytest --cov=src

代码格式化

# Format code
black src tests

# Lint code
ruff check src tests

项目结构

agenticrag-mcp/
├── src/                    # Source code
│   ├── agents/            # AI agents
│   ├── api/              # API endpoints
│   ├── indexing/         # Code indexing
│   └── storage/          # Vector storage
├── tests/                 # Test files
├── install.sh            # Installation script
├── requirements.txt      # Dependencies
└── .env.example         # Environment template

贡献

  1. 分叉存储库
  2. 创建要素分支: git checkout -b feature-name
  3. 进行更改和测试
  4. 提交拉取请求

许可证

MIT许可证-有关详细信息,请参阅许可证文件

支持

  • 问题:
  • 讨论:
  • 文档: 维基

目录标签

目录标签

代码索引PythonClaude代码检索本地部署语义搜索智能问答多模型架构

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP