MCP GitHub内存🧠
  ](https://nodejs.org/)  
让你的AI助手完美回忆起你的GitHub存储库历史
一个模型上下文协议(MCP)服务器,可以自动索引GitHub的pull请求和提交,使GitHub Copilot和Claude等AI助手可以搜索您的项目历史。
✨ 特性
- 🔄 自动索引 -GitHub webhooks触发PR和提交的实时索引
- 🔍 智能搜索 -按关键字、作者、存储库或状态查询
- 🔒 安全 -HMAC-SHA256 webhook验证,没有硬编码的秘密
- ⚡ 快速 -带索引的SQLite提供\|Webhook| B[MCP Server]
B -->|Index| C[SQLite DB] D[Copilot/Claude] -->|MCP Query| B B -->|Context| D
## 🚀 快速开始
### 先决条件
- Node.js 18+
- 具有管理员访问权限的GitHub存储库
- HTTPS端点(或用于测试的ngrok)
### 安装
Clone the repository
git clone https://github.com/AmedeoPelliccia/mcp-github-memory cd mcp-github-memory
Install dependencies
npm install
Build TypeScript
npm run build
Copy environment template
cp .env.example .env
Edit .env with your GITHUB_WEBHOOK_SECRET
### 运行服务器
#### 作为GitHub Webhook服务器
Start webhook server on port 3000
WEBHOOK_PORT=3000 GITHUB_WEBHOOK_SECRET=your-secret node dist/index.js webhook
#### 作为MCP服务器
Start MCP server (stdio mode)
node dist/index.js mcp
### 配置GitHub Webhook
1. 转到您的仓库→ **设置** → **网络钩子** → **添加webhook**
1. **有效载荷URL**: `https://your-domain.com/webhook`
1. **内容类型**: `application/json`
1. **秘密**:您的 `GITHUB_WEBHOOK_SECRET`
1. **事件**:选择“拉取请求”和“推送”
1. **保存**
### 配置AI助手
#### GitHub Copilot
1. 打开Copilot聊天设置
1. 添加MCP服务器
1. **统一资源定位符**:MCP服务器的路径
1. **命令**: `node /path/to/dist/index.js mcp`
#### 克劳德桌面
添加到 `claude_desktop_config.json`:
{ "mcpServers": { "github-memory": { "command": "node", "args": ["/absolute/path/to/dist/index.js", "mcp"], "env": { "GITHUB_MEMORY_DB_PATH": "/path/to/github-memory.db" } } } }
## 📡 MCP工具可用
|工具|说明|参数|
|------|-------------|------------|
| `search_pull_requests` |搜索索引PR| `query`, `repository`, `author`, `state` |
| `get_pull_request` |获取特定PR| `repository`, `number` |
| `search_commits` |搜索索引提交| `query`, `repository`, `author` |
| `get_commit` |获得具体承诺| `sha` |
## 💻 发展
### 与ngrok的地方发展
Terminal 1: Start server
npm run build && npm start webhook
Terminal 2: Expose via ngrok
ngrok http 3000
Use ngrok URL for GitHub webhook
### 测试
Run all tests
npm test
Watch mode during development
npm run test:watch
Build in watch mode
npm run watch
### 项目结构
mcp-github-memory/ ├── src/ │ ├── database.ts # SQLite operations │ ├── webhook.ts # GitHub webhook handler │ ├── mcp-server.ts # MCP protocol implementation │ └── index.ts # Main entry point ├── tests/ │ └── database.test.ts # Comprehensive test suite ├── dist/ # Compiled JavaScript ├── package.json # Dependencies & scripts ├── tsconfig.json # TypeScript configuration └── .env.example # Environment template
## 🔐 安全
- ✅ **Webhook验证** -HMAC-SHA256签名验证
- ✅ **环境变量** -没有硬编码的秘密
- ✅ **类型安全** -带有严格模式的完整TypeScript
- ✅ **SQL注入保护** -参数化查询
- ✅ **最小依赖性** -仅限基本套餐
## 📊 查询示例
### 在GitHub上进行Copilot聊天
User: "Show me PRs about authentication" Copilot: [Searches via MCP] Found PR #42 "Add OAuth2 authentication"...
User: "What commits mention the API refactor?" Copilot: [Queries commits] Found 3 commits from last week...
### 直接MCP工具调用
{ "tool": "search_pull_requests", "arguments": { "query": "authentication", "state": "merged" } }
## 🧪 测试覆盖率
✅ Database Operations ✓ Creates database with correct schema ✓ Inserts and retrieves pull requests ✓ Searches pull requests by query ✓ Inserts and retrieves commits ✓ Searches commits by message ✓ Handles upsert operations
Test Suites: 1 passed Tests: 6 passed Coverage: 100%
## 🗺️ 路线图
- \[\]使用SQLite FTS5进行全文搜索
- \[\]问题和评论索引
- \[\]语义搜索的向量嵌入
- \[\]PostgreSQL扩展适配器
- \[\]Web UI仪表板
- \[\]普罗米修斯指标
- \[\]多存储库支持
- \[\]GitLab/Bitbucket适配器
## 🤝 贡献
欢迎投稿!请随时提交拉取请求。
1. 分叉存储库
1. 创建功能分支(`git checkout -b feature/AmazingFeature`)
1. 运行测试(`npm test`)
1. 提交您的更改(`git commit -m 'Add some AmazingFeature'`)
1. 推到分支(`git push origin feature/AmazingFeature`)
1. 打开拉取请求
## 📄 许可证
此项目根据MIT许可证获得许可-请参阅 [许可证](LICENSE) 文件以获取详细信息。
## 🙏 致谢
- [模型上下文协议](https://modelcontextprotocol.io) 规格
- [Anthropic](https://anthropic.com) 用于MCP设计
- 文档
- 开源社区
## ⭐ 明星历史
[](https://star-history.com/#AmedeoPelliccia/mcp-github-memory&Date)
______________________________________________________________________
Built with ❤️ for the AI-assisted development community
⭐ Star this project •
🐛 Report Bug •
💡 Request Feature
