Claude MCP知识库
消除重复的MCP研究 -用于模型上下文协议(MCP)开发的持久知识库服务器,具有GitHub集成和删除块列表功能。
特性
- 零研究MCP创建:内置MCP规范、最佳实践和模式知识
- 始终保持最新:从官方MCP存储库和社区示例自动同步
- GitHub集成:索引您的
.claude/所有存储库中的目录 - 删除阻止列表:跟踪已删除的MCP并永久排除文件模式
- 定期同步:每30分钟自动更新一次知识库(可配置)
- 快速搜索:在所有索引文档中进行基于关键字的搜索
快速开始
先决条件
- Node.js≥18
- GitHub个人访问令牌(用于索引仓库)
安装
npm install -g @grandinharrison/claude-mcp-kb或与 npx:
npx @grandinharrison/claude-mcp-kb设置
- 设置GitHub令牌:
export GITHUB_TOKEN="your_github_pat_here"或者使用Claude Code进行身份验证(令牌将从以下位置自动检测 ~/.claude/.credentials.json).
- 添加到克劳德代码:
添加到您的 .claude/settings.json:
{
"mcpServers": {
"knowledge-base": {
"command": "npx",
"args": ["-y", "@grandinharrison/claude-mcp-kb"],
"env": {
"GITHUB_TOKEN": "your_token_here"
}
}
}
}或者使用CLI:
claude mcp add --transport stdio knowledge-base -- npx @grandinharrison/claude-mcp-kb- 首次运行:
服务器将自动:
- 创建
~/.claude-kb/目录 - 索引官方MCP存储库
- 通过以下方式发现您的存储库
.claude/目录 - 开始定期同步(每30分钟一次)
用法
可用工具
search_knowledge_base
搜索MCP文档、示例和最佳实践。
{
"query": "how to implement MCP tool with error handling",
"maxResults": 10
}退货:使用片段和源文件对搜索结果进行排名。
get_mcp_specification
获取当前的MCP协议规范、最佳实践和常见模式。
{}退货:完整的MCP规范,包括生命周期、传输和功能。
list_repositories
列出所有带有文件计数的索引存储库。
{}退货:带有计数的存储库列表。
add_blocklist_entry
将MCP服务器或文件模式添加到块列表中。
{
"type": "file_pattern",
"pattern": "**/*.secret.md",
"reason": "Contains sensitive information"
}或者屏蔽服务器:
{
"type": "server",
"serverName": "@example/bad-mcp-server",
"reason": "Security vulnerability"
}check_blocklist
检查是否有东西被堵住了。
{
"serverName": "@example/my-server"
}update_knowledge_base
手动触发同步(通常为自动)。
{
"force": true
}配置
编辑 ~/.claude-kb/config.json:
{
"version": "1.0.0",
"repositories": [
{
"owner": "your-org",
"repo": "your-repo",
"branch": "main",
"includePatterns": [".claude/**/*.md"],
"excludePatterns": ["**/node_modules/**"],
"indexingEnabled": true,
"type": "user"
}
],
"sync": {
"enabled": true,
"intervalMinutes": 30,
"autoDiscoverUserRepos": true,
"includeOfficialMCPRepos": true,
"includeCommunityRepos": true
},
"storage": {
"cacheDir": "~/.claude-kb",
"maxIndexSizeMB": 1000
},
"blocklist": {
"enabled": true,
"strict": true
}
}配置选项
- 仓库:显式配置repos以进行索引
- sync.intervalMinutes:同步的频率(5-1440分钟)
- sync.autoDiscoverUserRepos:使用自动查找您的存储库
.claude/目录 - sync.include官方网站:索引模型上下文协议/\*repos
- sync.includeCommunityRepos:索引出色的mcp服务器列表
- blocklist.strict:阻止而不提示用户
阻止列表
阻止列表存储在 ~/.claude-kb/data/blocklist.json 作为一个 仅附加日志.
阻止文件模式
{
"type": "file_pattern",
"pattern": "**/private/**",
"reason": "Exclude private directories"
}阻止MCP服务器
{
"type": "server",
"serverName": "@malicious/mcp-server",
"version": "1.0.0",
"reason": "Security vulnerability CVE-2025-12345"
}移除是永久性的
一旦被阻止,条目将永远保留在日志中(除非手动编辑)。要覆盖,请执行以下操作:
- 编辑
~/.claude-kb/data/blocklist.json - 集
allowOverride: true在入口处 - 重新启动服务器
存储结构
~/.claude-kb/
├── config.json # Configuration
├── data/
│ ├── specification.json # MCP spec cache
│ └── blocklist.json # Blocklist log
├── repos/ # Cached repository content
│ ├── modelcontextprotocol/
│ │ └── servers/
│ └── your-username/
│ └── your-repo/
└── templates/ # MCP templates (future)发展
从源代码构建
git clone https://github.com/grandinharrison/claude-mcp-kb.git
cd claude-mcp-kb
npm install
npm run build在开发模式下运行
npm run dev运行测试
npm test路线图
电流(v0.1.0)
- ✅ 基本关键字搜索
- ✅ GitHub集成
- ✅ 定期同步
- ✅ 阻止列表(服务器+文件模式)
- ✅ 官方MCP回购指数
- ✅ 自动发现用户存储库
计划(v0.2.0)
- \[\]矢量搜索(txtai/FAISS集成)
- \[\]语义相似性评分
- \[\]MCP服务器模板生成
- \[\]实时webhook同步
- \[\]用于块列表管理的Web UI
未来
- \[\]多云支持(GitLab、Bitbucket)
- \[\]团队协作功能
- \[\]使用情况分析
- \[\]知识图关系
故障排除
“未找到GitHub令牌”
集 GITHUB_TOKEN 环境变量或使用克劳德代码进行身份验证。
“获取仓库时出错”
检查:
- 令牌具有
repo范围 - 存储库已存在,您有权访问
- 网络连接
知识库未更新
- 检查
~/.claude-kb/config.json-确保sync.enabled: true - 手动触发:
update_knowledge_base工具 - 检查stderr输出中的日志
搜索速度慢
当前MVP使用关键字搜索。升级到v0.2.0中的矢量搜索,以实现更快的语义搜索。
贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支
- 添加新功能的测试
- 提交拉取请求
许可证
MIT许可证-请参阅许可证文件
作者
哈里森·格兰丁
致谢
- 建立在 @模型上下文协议/sdk
- 受到MCP社区的启发
- 特别感谢Anthropic为Claude Code所做的贡献
