关于 CodeWiki MCP — AI-generated docs for GitHub repos
codewiki-mcp 是面向 AI 助手的 MCP 服务,可搜索 codewiki.google 收录的 GitHub 仓库、获取生成的 Wiki 文档并回答仓库问题。它支持多种传输方式,也能从自然语言解析仓库名称。
主要功能
- 01搜索已收录的仓库
- 02获取完整或结构化 Wiki 页面
- 03结合对话历史提问
- 04从自然语言解析仓库
- 05支持 stdio、Streamable HTTP 和 SSE
适用场景
- 01按主题查找仓库
- 02阅读仓库的生成式文档
- 03询问仓库功能的工作原理
MCP 相关
通过 MCP 工具提供仓库搜索、文档获取和问答,并连接至 codewiki.google。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
3收录的工具列表 · 更新于 2 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | integer | 否 | |
| query | string | 是 |
详细介绍
📚 codewiki-mcp
面向 codewiki.google 的 MCP 服务——搜索、获取文档,并询问任何开源仓库的问题
🇷🇺 Русский | 🇬🇧 English
将任意 AI 助手连接到 codewiki.google 的 MCP 服务——该网站为开源仓库生成 AI Wiki 文档。
📖 概览
codewiki-mcp 是一款 Model Context Protocol 服务,可让 AI 助手访问 codewiki.google——这项服务可为任意 GitHub 仓库生成全面的 Wiki 文档。搜索仓库、获取完整文档,或用自然语言提问——所有操作都通过 MCP 完成。
✨ 功能
| 功能 | 描述 |
|---|---|
| 🔍 搜索仓库 | 查找由 codewiki.google 编入索引的仓库 |
| 📄 获取 Wiki 文档 | 获取任意仓库的完整 Markdown 文档或结构化页面 |
| 💬 提问 | 支持对话历史的自然语言问答 |
| 🧠 NLP 仓库解析 | 使用自然语言输入——wink-nlp 会提取关键词并解析为 owner/repo |
| 📡 多种传输方式 | stdio(默认)、Streamable HTTP、SSE |
| 🔄 退避重试 | 遇到 5xx 错误时自动进行指数退避重试 |
| 🐳 Docker 支持 | 多阶段 Alpine 构建 |
| 📊 响应元数据 | 每个响应均包含字节数和耗时 |
🚀 快速开始
使用 npx(无需安装)
npx -y codewiki-mcp@latest
从源代码构建
git clone https://github.com/izzzzzi/codewiki-mcp.git
cd codewiki-mcp
npm install
npm run build
传输方式
# stdio (default)
node dist/cli.js
# Streamable HTTP
node dist/cli.js --http --port 3000
# SSE
node dist/cli.js --sse --port 3001
🐳 Docker
docker build -t codewiki-mcp .
# stdio
docker run -it --rm codewiki-mcp
# HTTP
docker run -p 3000:3000 codewiki-mcp --http
# with environment variables
docker run -p 3000:3000 \
-e CODEWIKI_REQUEST_TIMEOUT=60000 \
-e CODEWIKI_MAX_RETRIES=5 \
-e GITHUB_TOKEN=ghp_your_token \
codewiki-mcp --http
🔧 MCP 客户端配置
Cursor
添加到 .cursor/mcp.json:
{
"mcpServers": {
"codewiki-mcp": {
"command": "npx",
"args": ["-y", "codewiki-mcp@latest"]
}
}
}
Claude Desktop
添加到 claude_desktop_config.json:
{
"mcpServers": {
"codewiki-mcp": {
"command": "npx",
"args": ["-y", "codewiki-mcp@latest"]
}
}
}
Claude Code
claude mcp add codewiki-mcp -- npx -y codewiki-mcp@latest
Windsurf
添加到 Windsurf MCP 配置中:
{
"mcpServers": {
"codewiki-mcp": {
"command": "npx",
"args": ["-y", "codewiki-mcp@latest"]
}
}
}
VS Code(Copilot)
添加到 .vscode/mcp.json:
{
"servers": {
"codewiki-mcp": {
"command": "npx",
"args": ["-y", "codewiki-mcp@latest"]
}
}
}
本地开发
{
"mcpServers": {
"codewiki-mcp": {
"command": "node",
"args": ["/path/to/codewiki-mcp/dist/cli.js"]
}
}
}
💡 使用方法
可在任何兼容 MCP 的客户端中使用的提示词:
codewiki fetch how routing works in Next.js
codewiki search state management libraries
codewiki ask how does React fiber reconciler work?
获取完整文档:
codewiki fetch vercel/next.js
codewiki fetch https://github.com/fastify/fastify
获取结构化页面:
codewiki fetch pages tailwindlabs/tailwindcss
使用自然语言提问:
codewiki ask fastify how to add authentication?
🛠️ MCP 工具
🔍 codewiki_search_repos
搜索由 codewiki.google 编入索引的仓库。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
query | string | ✅ | — | 搜索查询 |
limit | number | — | 10 | 最大结果数(1–50) |
📄 codewiki_fetch_repo
获取仓库生成的 Wiki 内容。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
repo | string | ✅ | — | owner/repo、GitHub URL 或自然语言查询 |
mode | string | — | "aggregate" | "aggregate" — 完整 Markdown;"pages" — 结构化 JSON |
💬 codewiki_ask_repo
用自然语言提问有关仓库的问题。
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
repo | string | ✅ | — | 仓库标识符(与 fetch 使用相同格式) |
question | string | ✅ | — | 有关仓库的问题 |
history | array | — | [] | 对话历史 [{role, content}](最多 20 条) |
📊 响应格式
✅ 成功 — 搜索
{
"query": "fastify",
"count": 1,
"items": [
{
"fullName": "fastify/fastify",
"url": "https://github.com/fastify/fastify",
"description": "Fast and low overhead web framework",
"avatarUrl": "https://avatars.githubusercontent.com/u/24939....",
"extraScore": 555
}
],
"meta": {
"totalBytes": 12500,
"totalElapsedMs": 450
}
}
✅ 成功 — 获取(pages 模式)
{
"repo": "fastify/fastify",
"commit": "abc123",
"canonicalUrl": "https://github.com/fastify/fastify",
"pages": [
{
"title": "Overview",
"level": 1,
"anchor": "#overview",
"markdown": "# Overview\n\nFastify is a web framework...",
"diagramCount": 1
}
],
"meta": {
"totalBytes": 25000,
"totalElapsedMs": 1200
}
}
✅ 成功 — 提问
{
"answer": "Fastify uses a plugin-based architecture where...",
"meta": {
"totalBytes": 8500,
"totalElapsedMs": 2300
}
}
❌ 错误响应
{
"error": {
"code": "RPC_FAIL",
"message": "CodeWiki RPC VSX6ub failed with status 404",
"rpcId": "VSX6ub",
"statusCode": 404
}
}
错误代码:VALIDATION、RPC_FAIL、TIMEOUT、NLP_RESOLVE_FAIL
⚙️ 工作原理
数据流
AI Assistant → MCP protocol → codewiki-mcp → HTTPS → codewiki.google
↓
AI Assistant ← MCP protocol ← codewiki-mcp ← JSON ← Google RPC API
Google Batchexecute RPC
codewiki.google 使用 Google 内部的 batchexecute RPC 格式(不是 REST,也不是 GraphQL)。客户端会:
- 使用
f.req=...请求正文构建 POST 请求 - 将请求发送到
/_/BoqAngularSdlcAgentsUi/data/batchexecute - 接收带有 XSSI 前缀
)]}'\n的响应 - 解析
wrb.fr帧并提取类型化负载
每个工具都对应一个 RPC ID:
| 工具 | RPC ID |
|---|---|
| 🔍 搜索 | vyWDAf |
| 📄 获取 | VSX6ub |
| 💬 提问 | EgIxfe |
🧠 NLP 仓库解析
用户可以输入自然语言,而不是 owner/repo:
"the fastify web framework"
→ wink-nlp extracts keyword "fastify" (POS tag: NOUN/PROPN)
→ GitHub Search API: GET /search/repositories?q=fastify&sort=stars
→ top result: "fastify/fastify"
→ normalizeRepoInput("fastify/fastify") → URL for codewiki
🔄 指数退避重试
| 尝试次数 | 延迟 |
|---|---|
| 0 | 立即 |
| 1 | 250ms |
| 2 | 500ms |
| 3 | 1000ms |
4xx 错误(客户端错误)绝不会重试。
🖥️ 命令行
codewiki-mcp [options]
Options:
--http Streamable HTTP transport
--sse SSE transport
--port <number> Port for HTTP/SSE (default: 3000)
--endpoint <str> URL endpoint (default: /mcp)
--help, -h Show help
⚡ 配置
环境变量:
| 变量 | 默认值 | 描述 |
|---|---|---|
CODEWIKI_BASE_URL | https://codewiki.google | 基础 URL |
CODEWIKI_REQUEST_TIMEOUT | 30000 | 请求超时时间(ms) |
CODEWIKI_MAX_RETRIES | 3 | 最大重试次数 |
CODEWIKI_RETRY_DELAY | 250 | 基础重试延迟(ms) |
GITHUB_TOKEN | — | 用于 NLP 仓库解析的 GitHub 令牌 |
你也可以在项目根目录创建 .env 文件:
CODEWIKI_REQUEST_TIMEOUT=60000
CODEWIKI_MAX_RETRIES=5
GITHUB_TOKEN=ghp_your_token
📁 项目结构
src/
├── cli.ts # CLI entry point
├── server.ts # Transport setup (stdio/HTTP/SSE)
├── index.ts # Library re-exports
├── schemas.ts # Zod input schemas
├── lib/
│ ├── codewikiClient.ts # API client with retry + metadata
│ ├── batchexecute.ts # Google RPC response parser
│ ├── repo.ts # Repo normalization + NLP resolution
│ ├── extractKeyword.ts # NLP keyword extraction (wink-nlp)
│ ├── resolveRepo.ts # GitHub Search API resolver
│ ├── errors.ts # CodeWikiError + formatMcpError
│ └── config.ts # Env-based configuration
└── tools/
├── searchRepos.ts # codewiki_search_repos
├── fetchRepo.ts # codewiki_fetch_repo
└── askRepo.ts # codewiki_ask_repo
❓ 故障排除
权限被拒绝
chmod +x ./node_modules/.bin/codewiki-mcp
连接被拒绝(HTTP/SSE)
# Check if port is in use
lsof -i :3000
超时错误
对于大型仓库,请延长超时时间:
CODEWIKI_REQUEST_TIMEOUT=60000 node dist/cli.js
NLP 解析失败
如果自然语言输入无法解析,请使用明确格式:
# Instead of "the fastify framework"
fastify/fastify
# or
https://github.com/fastify/fastify
设置 GITHUB_TOKEN,以避免未通过身份验证的请求触发 GitHub API 速率限制。
🧑💻 开发
npm run dev # stdio with tsx
npm run dev:http # HTTP with tsx
npm run dev:sse # SSE with tsx
npm run typecheck # type check
npm run test # run tests
npm run test:watch # tests in watch mode
npm run build # compile to dist/
🤝 贡献
欢迎贡献!请:
- Fork 此仓库
- 创建功能分支(
git checkout -b feat/my-feature) - 使用 Conventional Commits 编写提交消息
- 提交前运行
npm run typecheck && npm run test - 发起 Pull Request
📄 许可证
MIT © codewiki-mcp 贡献者
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。