GitHub Wiki MCP服务器
MCP(模型上下文协议)服务器,用于以编程方式管理GitHub wiki页面。
特性
此MCP服务器公开了以下工具:
write_wiki_page-创建或更新wiki页面read_wiki_page-阅读维基页面的内容append_to_wiki_page-将内容附加到现有页面list_wiki_pages-列出存储库中的所有wiki页面delete_wiki_page-删除wiki页面
安装
# Install dependencies
pnpm install
# Build the TypeScript project
pnpm build配置
1.创建GitHub个人访问令牌
- 转到GitHub→ 设置→ 开发者设置→ 个人访问令牌→ 代币(经典)
- 点击“生成新令牌(经典)”
- 选择
repo范围(访问存储库wiki) - 复制生成的令牌
2.将MCP服务器添加到Claude Desktop配置中
编辑配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - 视窗:
%APPDATA%\Claude\claude_desktop_config.json
添加此配置:
{
"mcpServers": {
"github-wiki": {
"command": "node",
"args": [
"/absolute/path/to/github_wiki_mcp/dist/index.js"
]
}
}
}替换 /absolute/path/to/github_wiki_mcp 带有项目目录的实际路径。
3.重新启动克劳德桌面
关闭并重新打开Claude Desktop以加载新的MCP服务器。
用法
示例:编写一个关于架构的wiki页面
你可以告诉克劳德:
Analyze the codebase using code-analysis-context-mcp to extract
all information about the repository architecture and write
a dedicated wiki page on GitHub called Architecture.克劳德将:
- 使用
code_analysis获取架构信息的工具 - 生成结构化的降价内容
- 使用
write_wiki_page在GitHub上创建页面
直接示例:创建wiki页面
Create a wiki page called "API Documentation" on the repository
myusername/myrepo with this content:
# API Documentation
## Main Endpoints
- GET /api/users
- POST /api/users
- DELETE /api/users/:id示例:读取现有页面
Read the content of the wiki page "Architecture" from the repository
myusername/myrepo示例:更新现有页面
Add a "Deployment" section to the wiki page "Architecture"
with deployment instructions工具参考
write_wiki_page
创建或完全覆盖wiki页面。
参数:
owner(string,必填):GitHub用户名或组织repo(字符串,必填):存储库名称token(string,必填):GitHub个人访问令牌pageName(字符串,必填):页面名称(例如“架构”)content(string,必填):页面的Markdown内容commitMessage(字符串,可选):自定义提交消息
输出:
{
"success": true,
"page": "Architecture.md",
"url": "https://github.com/owner/repo/wiki/Architecture"
}read_wiki_page
读取现有wiki页面的内容。
参数:
owner,repo,token:与上述相同pageName(string,必填):要读取的页面的名称
输出:
{
"success": true,
"page": "Architecture.md",
"content": "# Architecture\n\n..."
}append_to_wiki_page
将内容附加到现有页面的末尾(如果不存在,则创建内容)。
参数:
owner,repo,token:与上述相同pageName(字符串,必填):页面名称content(string,必填):要附加的内容commitMessage(字符串,可选):提交消息
list_wiki_pages
列出存储库中的所有wiki页面。
参数:
owner,repo,token:与上述相同
输出:
[
{
"name": "Architecture",
"path": "Architecture.md",
"size": 2048
},
{
"name": "API-Documentation",
"path": "API-Documentation.md",
"size": 1024
}
]delete_wiki_page
删除wiki页面。
参数:
owner,repo,token:与上述相同pageName(string,必填):要删除的页面的名称commitMessage(字符串,可选):提交消息
运作原理
服务器使用wiki Git存储库(.wiki.git)而不是GitHub的REST API:
- 将wiki存储库克隆到临时目录
- 执行请求的操作(创建/修改/删除
.md文件) - 承诺并推动变革
- 清理临时目录
这种方法:
- 比用于wiki的REST API更可靠
- 支持所有标准Git操作
- 没有内容大小限制
- 适用于私有存储库(如果令牌具有权限)
与其他MCP集成
随着 code-analysis-context-mcp
您可以将此服务器与您的 code-analysis-context-mcp 致:
- 自动分析代码库
- 提取文档、架构、API
- 自动编写更新的wiki页面
工作流程示例:
Analyze the repository using code-analysis-context-mcp,
extract the complete architecture and create three wiki pages:
1. Architecture - overall project structure
2. API - endpoint documentation
3. Database - schema and relationships克劳德将使用:
code_analysis.get_repository_architecture→ 分析github_wiki.write_wiki_page→ 架构页面github_wiki.write_wiki_page→ API页面github_wiki.write_wiki_page→ 数据库页
安全
- 永远不要分享你的GitHub代币:令牌可以完全访问存储库
- 使用范围最小的令牌:只有
repo必要的 - 考虑使用过期令牌:适用于生产环境
- 不要提交令牌:确保仅在运行时提供
发展
# Watch mode during development
pnpm dev
# Production build
pnpm build
# Local installation for testing
pnpm link故障排除
服务器未连接
- 验证中的路径
claude_desktop_config.json绝对正确 - 检查一下
pnpm build已执行 - 验证克劳德桌面日志
认证错误
- 验证GitHub令牌是否有效
- 检查令牌是否具有
repo范围 - 确保存储库已启用wiki(设置→ Wiki)
Wiki不存在
GitHub仅在手动创建第一页时自动创建wiki存储库。如果存储库从未有过wiki:
- 首选
https://github.com/owner/repo/wiki - 点击“创建第一页”
- 创建测试页面
- 现在MCP服务器将能够访问wiki
许可证
麻省理工学院
