启动ART MCP服务器
  ](https://www.docker.com) 
⚡ 基于快速自适应根树(ART)的MCP服务器 交付 微秒延迟 大型语言模型的结构化内存访问。用Rust构建 零V8开销 和 系统性能.
此服务器实现 模型上下文协议 因此,任何兼容MCP的LLM都可以通过JSON-RPC查询结构化内存。
🚀 性能特征
| 数据集大小 | 查找P95 | 前缀扫描(100个匹配项) | 内存使用情况 |
|---|---|---|---|
| 100k密钥 | 8µs | 35µs | 12 MB |
| 1M钥匙 | 11µs | 60µs | 85 MB |
备注:性能数字主要由JSON序列化而不是ART遍历主导,这展示了卓越的核心效率。
🏗️ 建筑
┌─────────────────┐ MCP Protocol ┌──────────────────┐
│ LLM Host │◄──────────────────►│ Memory Server │
│ (Claude/etc.) │ JSON-RPC 2.0 │ (Rust + ART) │
└─────────────────┘ └──────────────────┘
│
▼
┌──────────────┐
│ Adaptive │
│ Radix Tree │
│ In-Memory │
└──────────────┘关键技术
- 🦀 锈:内存安全、零成本抽象、可预测的性能
- 🌳 适应性根树:O(k)操作,每个键8-52字节,缓存友好
- 🔌 模型上下文协议:通过JSON-RPC 2.0标准化LLM集成
- 🐳 码头工人:静态链接的无发行版容器(\ JSON file with entity data to preload
--events JSON file with event data to preload --ws WebSocket address (e.g., 0.0.0.0:4000) --event-limit Max events returned by prefix search [default: 64] --health-port Health check port [default: 3000] --telemetry Enable OpenTelemetry tracing --health-check Run health check and exit (for containers)
### 环境变量
Logging
RUST_LOG=info # Log level OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger:4317 # Telemetry endpoint
Performance tuning (set automatically)
MIMALLOC_LARGE_OS_PAGES=1 # Use huge pages if available
## 📊 MCP协议接口
服务器通过MCP公开了两个主要工具:
### 1.实体查找
{ "tool": "lookupEntity", "arguments": { "name": "Albert Einstein" } }
**答复:**
{ "name": "Albert Einstein", "summary": "Theoretical physicist, Nobel Prize 1921...", "born": "1879", "tags": ["physicist", "relativity", "nobel"] }
### 2.事件搜索
{ "tool": "findEvents", "arguments": { "prefix": "2023-11" } }
**答复:**
[ { "id": "2023-11-01:meeting", "timestamp": "2023-11-01T10:00:00Z", "description": "Team standup meeting", "category": "work" } ]
## 🏭 生产特点
### 安全强化
- ✅ **非根容器** 使用无发行版基础映像
- ✅ **只读文件系统** 能力下降
- ✅ **SBOM生成** 供应链安全
- ✅ **漏洞扫描** 与Trivy
- ✅ **网络策略** 用于微细分
### 可观测性
- ✅ **健康检查** (`/health/live`, `/health/ready`)
- ✅ **普罗米修斯指标** (`/metrics`)
- ✅ **结构化日志记录** JSON输出
- ✅ **OpenTetry跟踪** 对于分布式系统
- ✅ **平滑关闭** 使用统计记录
### 高可用性
- ✅ **水平Pod自动缩放** (2-10个副本)
- ✅ **Pod中断预算** 用于滚动更新
- ✅ **反亲和规则** 用于区域分布
- ✅ **资源限制** 以及服务质量
## 🔬 性能优化
### 内存分配器
// 2-6x performance improvement with custom allocator #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
### 零拷贝序列化
// 10-50x faster than standard JSON with rkyv use rkyv::{Archive, Serialize, Deserialize};
### 缓存对齐数据结构
// Optimize for CPU cache lines #[repr(align(64))] struct AlignedMemory { ... }
## 📈 基准测试
Run performance benchmarks
cargo bench
Memory profiling
cargo run --release -- --entities large_dataset.json & ps aux | grep blazing_art_mcp # Check RSS memory
Load testing with WebSocket
wrk -t12 -c400 -d30s http://localhost:4000/
## 🛠️ 发展
### 从源头构建
Development build
cargo build
Optimized release build
cargo build --release
With all security features
cargo build --release --target x86_64-unknown-linux-musl
### 测试
Unit tests
cargo test
Integration tests
cargo test --test integration
Clippy linting
cargo clippy -- -D warnings
Security audit
cargo audit
### 集装箱开发
Development container with hot reload
docker build --target development -t mcp-memory:dev . docker run -v $(pwd):/app mcp-memory:dev
Security scanning
docker build --target security-scan -t mcp-memory:scan . docker run --rm mcp-memory:scan cat /tmp/trivy-report.sarif
## 🔄 数据管理
### 荷载数据
**实体** (`entities.json`):
[ { "name": "Claude Shannon", "summary": "Father of information theory...", "born": "1916", "tags": ["mathematician", "information-theory"] } ]
**事件** (`events.json`):
[ { "id": "2024-01-15:discovery", "timestamp": "2024-01-15T14:30:00Z", "description": "Major breakthrough in quantum computing", "category": "science" } ]
### 坚持策略
1. **快照加载**:装载JSON文件以进行初始数据加载
1. **运行时更新**:使用MCP工具进行动态突变
1. **优雅的坚持**:关闭信号时刷新到磁盘
## 🐛 故障排除
### 常见问题
**容器未通过健康检查:**
Check health endpoint directly
docker exec -it /blazing_art_mcp --health-check
Verify port binding
docker ps | grep mcp-memory
**内存使用率高:**
Check ART statistics
curl http://localhost:3000/metrics
Verify data size vs memory usage ratio
**性能下降:**
Enable debug logging
RUST_LOG=debug ./blazing_art_mcp
Check for JSON serialization bottlenecks in traces
## 📝 许可证
MIT许可证-请参阅 [许可证](LICENSE) 了解详情。
## 🤝 贡献
1. 分叉存储库
1. 创建要素分支: `git checkout -b feature/amazing-feature`
1. 提交更改: `git commit -m 'Add amazing feature'`
1. 推送到分支: `git push origin feature/amazing-feature`
1. 打开拉取请求
## 🙏 致谢
- [Anthropic](https://anthropic.com) 对于模型上下文协议
- [美术纸](https://db.in.tum.de/~leis/papers/ART.pdf) 由Leis等人。
- [艺术树](https://crates.io/crates/art-tree) Rust实现
- [rmcp](https://github.com/modelcontextprotocol/rust-sdk) 官方Rust MCP SDK
______________________________________________________________________
**内置于❤️ 面向人工智能应用的未来**