mcpField
C
CodeWiki MCP — AI-generated docs for GitHub repos

CodeWiki MCP — AI-generated docs for GitHub repos

本地服务
github.com/izzzzzi开发工具1928 周前更新

关于 CodeWiki MCP — AI-generated docs for GitHub repos

codewiki-mcp 是面向 AI 助手的 MCP 服务,可搜索 codewiki.google 收录的 GitHub 仓库、获取生成的 Wiki 文档并回答仓库问题。它支持多种传输方式,也能从自然语言解析仓库名称。

主要功能

  1. 01搜索已收录的仓库
  2. 02获取完整或结构化 Wiki 页面
  3. 03结合对话历史提问
  4. 04从自然语言解析仓库
  5. 05支持 stdio、Streamable HTTP 和 SSE

适用场景

  1. 01按主题查找仓库
  2. 02阅读仓库的生成式文档
  3. 03询问仓库功能的工作原理

MCP 相关

通过 MCP 工具提供仓库搜索、文档获取和问答,并连接至 codewiki.google。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"izzzzzi-codewiki": {
"command": "npx",
"args": [
"-y",
"codewiki-mcp"
]
}
}
}
启动命令npx -y codewiki-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmcodewiki-mcp1.1.1

工具

3

收录的工具列表 · 更新于 2 周前

参数类型必填说明
limitinteger否
querystring是

详细介绍

📚 codewiki-mcp

面向 codewiki.google 的 MCP 服务——搜索、获取文档,并询问任何开源仓库的问题

CI Release npm version npm downloads License: MIT TypeScript Node.js

🇷🇺 Русский | 🇬🇧 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 编入索引的仓库。

参数类型必填默认值描述
querystring✅—搜索查询
limitnumber—10最大结果数(1–50)
📄 codewiki_fetch_repo

获取仓库生成的 Wiki 内容。

参数类型必填默认值描述
repostring✅—owner/repo、GitHub URL 或自然语言查询
modestring—"aggregate""aggregate" — 完整 Markdown;"pages" — 结构化 JSON
💬 codewiki_ask_repo

用自然语言提问有关仓库的问题。

参数类型必填默认值描述
repostring✅—仓库标识符(与 fetch 使用相同格式)
questionstring✅—有关仓库的问题
historyarray—[]对话历史 [{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)。客户端会:

  1. 使用 f.req=... 请求正文构建 POST 请求
  2. 将请求发送到 /_/BoqAngularSdlcAgentsUi/data/batchexecute
  3. 接收带有 XSSI 前缀 )]}'\n 的响应
  4. 解析 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立即
1250ms
2500ms
31000ms

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_URLhttps://codewiki.google基础 URL
CODEWIKI_REQUEST_TIMEOUT30000请求超时时间(ms)
CODEWIKI_MAX_RETRIES3最大重试次数
CODEWIKI_RETRY_DELAY250基础重试延迟(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/

🤝 贡献

欢迎贡献!请:

  1. Fork 此仓库
  2. 创建功能分支(git checkout -b feat/my-feature)
  3. 使用 Conventional Commits 编写提交消息
  4. 提交前运行 npm run typecheck && npm run test
  5. 发起 Pull Request

📄 许可证

MIT © codewiki-mcp 贡献者

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。