🧠 知识MCP服务器
Claude代码的统一知识管理 -用于知识库、研究工作流程和文档智能的最全面的MCP服务器。
🚀 为什么选择知识MCP?
与仅存储和检索文档的基本知识库MCP不同, 知识MCP 是一个 统一知识生态系统 这改变了Claude Code代理处理信息的方式:
Traditional KB MCP: Knowledge-MCP:
┌─────────────┐ ┌─────────────────────────────────┐
│ Store │ │ KB + Research + Journal │
│ Search │ → │ + Document Intelligence │
│ Retrieve │ │ + Auto-sync + Link tracking │
└─────────────┘ └─────────────────────────────────┘🌟 统一架构
四个系统,一台服务器:
- 📚 知识库 -具有语义搜索的结构化文档存储
- 🔬 研究工作流程 -注释、来源、链接实验
- 📖 期刊系统 -决策日志和配置快照
- 🔍 文档智能 -自动摄取、变化检测、双向链接
🎯 关键优势
| 功能 | 传统知识库MCP | 知识MCP |
|---|---|---|
| 存储 | 单个文档 | 结构化知识+关系 |
| 研究 | 基本搜索 | 包含实验的完整研究工作流程 |
| 同步 | 手动更新 | 使用SHA-256哈希自动检测 |
| 链接 | 文本引用 | 双向源↔ KB链接 |
| 后端 | 单选 | PostgreSQL+Supabase+SQLite |
| 智能 | 静态存储 | 采用分块策略的文档摄取 |
⚡ 快速开始
1.安装
# Clone the repository
git clone https://github.com/your-username/knowledge-mcp.git
cd knowledge-mcp
# Install with PostgreSQL support
pip install -e .
# Or install from PyPI (coming soon)
pip install knowledge-mcp2.后端设置
选项A:PostgreSQL+pgvector(推荐)
# Run setup script
./scripts/setup-postgres.sh
# Configure environment
cp .env.example .env
# Edit DATABASE_URL in .env选项B:Supabase(云)
# Get credentials from Supabase dashboard
cp .env.example .env
# Edit SUPABASE_URL and SUPABASE_KEY选项C:SQLite(本地开发/工作机器)
# No setup needed - auto-creates a single .db file
export DB_BACKEND=sqlite
export KNOWLEDGE_DATA_DIR=/path/to/data # optional, defaults to ./knowledge-data3.克劳德代码集成
添加到您的Claude Code MCP配置中:
PostgreSQL:
{
"mcpServers": {
"knowledge-mcp": {
"command": "knowledge-mcp",
"env": {
"DB_BACKEND": "local",
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_NAME": "mmp_system",
"DB_USER": "your_user",
"DB_PASSWORD": "your_password",
"KNOWLEDGE_DATA_DIR": "/opt/knowledge-data"
}
}
}
}SQLite(不需要数据库服务器):
{
"mcpServers": {
"knowledge-mcp": {
"command": "knowledge-mcp",
"env": {
"DB_BACKEND": "sqlite",
"KNOWLEDGE_DATA_DIR": "/path/to/knowledge-data"
}
}
}
}4.开始使用
# Start the server
knowledge-mcp
# Or test directly
python -m knowledge_mcp.server📋 核心工具
📚 知识库
# Add structured knowledge
kb_add(topic="api-design", title="REST Best Practices", content="...")
# Intelligent search with ranking
kb_search(query="authentication patterns", limit=10)
# Bulk document ingestion
kb_ingest_dir(dir_path="/docs", strategy="chunked", recursive=True)🔬 研究工作流程
# Research notes with linking
research_add_note(title="OAuth2 Investigation", content="...", tags=["auth"])
# Track sources and experiments
research_add_source(url="https://oauth.net/2/", title="OAuth 2.0 Spec")
research_log_experiment(title="JWT vs Sessions", hypothesis="...", results="...")📖 日志和配置
# Decision logging
journal_append(content="Decided to use PostgreSQL for better performance")
# Configuration snapshots
snapshot_config(label="v2.1-release", paths=["/etc/app.conf"])🔍 文档智能
# Auto-sync with change detection
kb_sync_status(dir_path="/docs") # Check what's changed
kb_ingest_dir(dir_path="/docs") # Auto-update only changed files
# Bidirectional linking
kb_link_to_source(kb_id="kb_123") # Find source document🏗️ 建筑
多后端设计
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ PostgreSQL │ │ Supabase │ │ SQLite │
│ (Recommended) │ │ (Cloud) │ │ (Local Dev) │
│ │ │ │ │ │
│ • Best perf │ │ • Zero setup │ │ • No server │
│ • Full features │ │ • Managed │ │ • Single file │
│ • Self-hosted │ │ • Scalable │ │ • Portable │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│ │ │
└───────────────────────┼───────────────────────┘
│
┌─────────────────────┐
│ Knowledge MCP │
│ Unified Interface │
└─────────────────────┘文档智能管道
📄 Source Documents
│
▼
┌─────────────────┐
│ Change Detection│ ← SHA-256 hashing
│ (Skip if same) │
└─────────────────┘
│
▼
┌─────────────────┐
│ Content Parser │ ← Frontmatter + Markdown
│ (Extract meta) │
└─────────────────┘
│
▼
┌─────────────────┐
│ Chunking Engine │ ← Smart section splitting
│ (Headers/tokens)│
└─────────────────┘
│
▼
┌─────────────────┐
│ KB Storage + │ ← Bidirectional links
│ Link Tracking │
└─────────────────┘🛠️ 高级功能
智能文档处理
- 智能分块:按标题和标记限制自动拆分文档
- 变化检测:SHA-256哈希可防止不必要的重新处理
- 前线支援:从YAML标头中提取元数据
- 双向链接:从KB条目导航回源文件
研究工作流程集成
- 来源管理:跟踪URL、论文和参考文献
- 实验记录:假设→ 结果→ 结论
- 交叉链接:将笔记与来源和实验联系起来
- 基于标签的组织:灵活的分类系统
性能和可靠性
- 并发处理:并行文档摄取
- 连接池:高效的数据库连接
- 错误恢复:妥善处理个别故障
- 增量同步:仅处理更改的文档
📖 文档
🚀 演出
基准与基本知识库MCP:
| 操作 | 基本知识库MCP | 知识MCP |
|---|---|---|
| 文档搜索 | 200ms | 50ms(PostgreSQL) |
| 批量摄入 | 不支持 | 10文档/秒 |
| 更改检测 | 完全重新处理 | 跳过不变(1ms) |
| 交叉引用 | 手动 | 自动双向 |
🌍 用例
🏢 企业文档
- 自动同步公司wiki和文档
- 跟踪研究和决策过程
- 维护配置审计跟踪
🔬 研究项目
- 管理研究笔记、来源和实验
- 将多项调查的结果联系起来
- 跟踪假设演变和结果
💻 开发团队
- 自动同步代码文档和ADR
- 日志架构决策
- 维护模式和解决方案的知识库
🎓 个人知识管理
- 处理和整理个人笔记和文章
- 跟踪学习进度和实验
- 构建相互关联的知识图谱
🤝 贡献
我们欢迎捐款!看 贡献.md 用于:
- 开发设置说明
- 代码风格指南
- 测试程序
- 拉取请求流程
📜 许可证
MIT许可证-请参阅 许可证 了解详情。
🆘 支持
- 问题:
- 讨论:
- 文档: 全部文件
______________________________________________________________________
为克劳德代码而建 • 由MCP供电 • 针对智能进行了优化
