关于 Aikd Indexed Semantic & Bm25 Code Search For Ai Agents. Give Your Ai Instant Memory Of Your Codebase. Rust | Mcp Server.
AIKD 是面向 AI 编码 Agent 的本地代码库索引与搜索服务。它以 Rust 实现,结合 BM25 和向量搜索,并提供命令行、REST API 与持久会话记忆。
主要功能
- 01BM25 与向量混合搜索
- 02增量索引代码库
- 03持久化会话记忆
- 04文件变更时重新索引
- 05命令行与 REST API
适用场景
- 01按关键词或语义查找代码
- 02为编码 Agent 提供持久代码库上下文
- 03项目文件变更时更新索引
MCP 相关
AIKD 可作为 MCP 服务运行,提供扫描、查询、嵌入、统计、记忆和状态工具。它可向文档列出的编码 Agent 自动注册。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
🧠 AIKD
面向 AI 编码 Agent 的超快本地记忆层
让 Claude、Cursor 和 Cline 即刻记住整个代码库。 使用 Rust 编写。零云端依赖。0.21ms 内搜索 10,000 个片段。
🤔 为什么选择 AIKD?
问题: AI 编码 Agent 功能强大,却容易遗忘。每次新对话都从零开始——不记得你的代码库、编码模式和架构。
| 痛点 | 不使用 AIKD | 使用 AIKD |
|---|---|---|
| 😵 上下文遗忘 | Agent 每次会话都问“这个文件是做什么的?” | 即刻回忆整个代码库 |
| 🐌 搜索缓慢 | 基于 Python 的 RAG 每次查询耗时 500ms 以上 | 由 Rust 驱动的 BM25+Vector,仅需 0.21ms |
| ☁️ 云端依赖 | 代码发送到外部服务 | 100% 本地运行,数据不会离开你的设备 |
| 🔧 设置复杂 | 安装 Python、pip、CUDA、模型…… | 单个二进制文件,一条命令即可安装 |
AIKD 对比
| 功能 | grep | LlamaIndex | ai-devkit | AIKD |
|---|---|---|---|---|
| 速度 | 快 | 慢 | 中等 | ⚡ 0.21ms |
| 语义搜索 | ❌ | ✅ | ✅ | ✅ 混合搜索 |
| 仅本地运行 | ✅ | ❌ | ❌ | ✅ 100% |
| 原生支持 MCP | ❌ | ❌ | ❌ | ✅ 内置 |
| 内存用量 | 低 | 高(Python) | 高 | 📊 27% RAM |
| 设置时间 | 0s | 约 10min | 约 5min | ⏱️ 30s |
✨ 主要功能
🔍 搜索引擎
- 混合搜索:BM25(Tantivy)+ 向量搜索(ONNX all-MiniLM-L6-v2,384d)
- 互惠排序融合:智能组合关键词与语义搜索结果
- 增量索引:使用 Blake3 哈希,实现扫描零冗余
- 资源自适应:自动检测 CPU/GPU 并调整批次大小
🤖 AI 集成
- MCP 协议:原生支持 Model Context Protocol
- 7 种内置工具:
scan、query、embed、stats、remember、recall、status - 自动注册:适用于 Claude Code、Cursor、Cline、Continue、Windsurf、MiMoCode
- 会话记忆:跨会话持久保存对话上下文
🛠️ 开发者体验
- 单个二进制文件:无需 Python、Node 或其他依赖
- 文件监视器:文件更改时自动重新索引
- REST API:在端口 9090 上提供 HTTP 端点,支持自定义集成
- CLI 优先:通过终端全面掌控
🎬 实际演示

$ aikd init
✅ AIKD initialized for project
$ aikd scan
📊 Indexed 847 files, 12,453 chunks in 1.2s
$ aikd query "authentication flow"
1. src/auth/login.rs (Lines 45-89, Score: 0.923)
Implements JWT-based authentication with refresh tokens...
2. src/middleware/auth.rs (Lines 12-34, Score: 0.871)
Validates Bearer tokens on protected routes...
3. docs/architecture/auth.md (Lines 1-25, Score: 0.845)
Authentication flow diagram and security considerations...
📦 安装
推荐方式(一行命令)
Linux / macOS:
curl -sSf https://raw.githubusercontent.com/gelutjari/aikd/main/install.sh | bash
Windows(PowerShell):
irm https://raw.githubusercontent.com/gelutjari/aikd/main/install.ps1 | iex
其他方式
📦 从 crates.io 安装(需要 Rust)
cargo install aikd
🍺 Homebrew(macOS/Linux)
brew install gelutjari/tap/aikd
🔧 从源代码构建
git clone https://github.com/gelutjari/aikd.git
cd aikd
cargo build --release
cp target/release/aikd ~/.local/bin/
🐳 Docker
docker run -v $(pwd):/workspace -p 9090:9090 ghcr.io/gelutjari/aikd:latest
⚡ 快速开始(3 分钟)
步骤 1:初始化
cd your-project
aikd init
aikd init 会做什么?
根据你的项目类型(Rust、Node、Python、Go),使用智能默认值创建 ~/.aikd/config.yaml。它会检测 .git、Cargo.toml、package.json 等文件,并设置适当的文件筛选规则。
扫描期间会发生什么?
- 遍历目录树(跳过
node_modules、.git、target等) - 按语义边界(函数、标题)对文件分块
- 生成 BM25 索引(Tantivy)和向量嵌入(ONNX)
- 将所有内容存储在本地 SQLite 数据库中
步骤 3:搜索
# Keyword search (fast)
aikd query "error handling"
# Semantic search (smart)
aikd query "how does login work" --hybrid
# Get JSON output for scripting
aikd query "database connection" --json
步骤 4:连接到你的 AI Agent
Claude Code / Cursor / Cline
AIKD 会通过 MCP 自动注册。运行 aikd scan 后,只需重启 AI Agent。
MCP 配置位于 ~/.aikd/mcp.json:
{
"mcpServers": {
"aikd": {
"command": "aikd",
"args": ["serve"]
}
}
}
REST API
# Start the daemon
aikd daemon
# Query via HTTP
curl "http://localhost:9090/api/query?q=authentication&limit=5"
🎛️ 使用模式
┌─────────────────┐
│ How to use │
│ AIKD? │
└────────┬────────┘
│
┌────────────────┼────────────────┐
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ CLI │ │ MCP │ │ REST API │
│ Mode │ │ Server │ │ Daemon │
└──────────┘ └──────────┘ └──────────┘
Best for: Best for: Best for:
• Quick search • AI agents • Web apps
• Scripts • Claude Code • Custom UIs
• CI/CD • Cursor • Team shared
CLI 模式(默认):
aikd query "rust error handling" --limit 5
aikd stats
aikd status
MCP 服务(适用于 AI Agent):
aikd serve # Starts stdio MCP server
REST 守护进程(后台服务):
aikd daemon # Start in background
aikd daemon foreground # Start in foreground
aikd daemon-stop # Stop daemon
📊 基准测试结果

硬件: AMD EPYC 7B13、7.8GB RAM、NVMe SSD
| 操作 | 时间 | 吞吐量 |
|---|---|---|
| 索引 1,000 个文件 | 144ms | 6,934 个文件/秒 |
| BM25 搜索 | 0.21ms | 4,762 次查询/秒 |
| 混合搜索 | 0.35ms | 2,857 次查询/秒 |
| 并发(500) | 28ms | 17,669 次查询/秒 |
| 嵌入(批处理) | 12ms/批 | 约 800 个分块/秒 |
资源使用情况:
CPU: ████████░░░░░░░░░░░░ 22.9%
RAM: █████░░░░░░░░░░░░░░░ 27.4%
💡 实际情况: 人眨一次眼约需 300ms。在这段时间里,AIKD 可以在整个代码库中完成 857 次混合搜索。
⚙️ 配置
默认配置(~/.aikd/config.yaml):
version: 2.0.0
scan:
include_paths: ["."]
exclude_paths: ["node_modules", ".git", "target"]
include_extensions: ["rs", "ts", "py", "md", "json"]
follow_symlinks: false
chunk:
max_tokens: 1000
min_tokens: 100
embedding:
enabled: true
model: all-MiniLM-L6-v2
batch_size: auto
server:
rest_port: 9090
auth_token: null
cors_origins: ["*"]
🐌 低配机器(4GB RAM,2 核)
embedding:
enabled: true
batch_size: 8
device: cpu
resource:
mode: Low
💪 高配机器(32GB RAM,16 核,GPU)
embedding:
enabled: true
batch_size: 64
device: gpu
resource:
mode: Max
📝 仅包含文档的项目
scan:
include_extensions: ["md", "txt", "rst"]
exclude_paths: [".git"]
filter:
max_file_size: 524288 # 512KB
👥 团队共享
server:
rest_port: 9090
auth_token: "your-secret-token"
cors_origins:
- "https://your-team-app.com"
🏗️ 架构

┌─────────────────────────────────────────────────────────────┐
│ AIKD v2.0.0 │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
│ │ CLI │ │ MCP │ │ REST │ │ File Watcher│ │
│ │ (clap) │ │ (rmcp) │ │ (axum) │ │ (notify) │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └──────┬──────┘ │
│ │ │ │ │ │
│ └────────────┴────────────┴───────────────┘ │
│ │ │
│ ┌─────────────────────────┴──────────────────────────┐ │
│ │ Core Engine │ │
│ ├─────────────┬─────────────┬─────────────────────────┤ │
│ │ Scanner │ Chunker │ Session Manager │ │
│ │ (walkdir) │(pulldown- │ (conversation DB) │ │
│ │ │ cmark) │ │ │
│ └──────┬──────┴──────┬──────┴─────────────────────────┘ │
│ │ │ │
│ ┌──────┴──────┐ ┌────┴─────┐ ┌──────────────────────┐ │
│ │ Indexer │ │ Embedder │ │ Storage │ │
│ │ (Tantivy) │ │ (ONNX) │ │ (SQLite + WAL) │ │
│ │ BM25 + │ │ 384d │ │ + r2d2 pool │ │
│ │ HNSW ANN │ │ MiniLM │ │ + blake3 hashing │ │
│ └─────────────┘ └──────────┘ └──────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
详细说明请参阅 docs/ARCHITECTURE.md。
🆘 故障排除
诊断命令:
aikd status --json # System info
aikd stats # Index statistics
aikd daemon-pid # Check if daemon running
“未找到结果”
- 先运行
aikd scan - 检查
aikd stats,确认已索引的文件 - 尝试更宽泛的搜索词
- 检查配置中的
include_extensions
“模型未下载”
aikd model download
这会将约 90MB 的 ONNX 模型下载到 ~/.local/share/aikd/model/。
“端口 9090 已被占用”
# Change port in config
# ~/.aikd/config.yaml
server:
rest_port: 9091
或者停止现有进程:aikd daemon-stop
内存使用量过高
将资源模式设为 Low:
resource:
mode: Low
max_memory_mb: 512
MCP 无法连接到 Claude/Cursor
- 检查
~/.aikd/mcp.json是否存在 - 重启 AI Agent
- 验证
aikd serve是否正常运行:echo '{"jsonrpc":"2.0","method":"initialize","id":1}' | aikd serve
Windows:“找不到 vcruntime140.dll”
🤝 社区
获取帮助:
- 💬 GitHub 讨论区 — 提出问题
- 🐛 问题反馈 — 报告错误
- 📧 电子邮件:[email protected]
贡献者:
| 贡献 | 贡献者 |
|---|---|
| 🏗️ 架构与核心 | @gelutjari |
| 🔒 安全审计 | AI 辅助(MiMo) |
| ⚡ 性能优化 | 社区 |
| 📖 文档 | 社区 |
有关如何参与贡献,请参阅 CONTRIBUTING.md。
📄 许可证
MIT 许可证 — 详情请参阅 LICENSE。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。