📚 codewiki mcp
用于codewiki.google的MCP服务器——搜索、获取文档并询问有关任何开源仓库的问题
  ](https://www.npmjs.com/package/codewiki-mcp) ](https://www.npmjs.com/package/codewiki-mcp)   ](https://nodejs.org/)
🇷🇺 俄语 | 🇬🇧 英语
*连接任何AI助手的MCP服务器 codewiki.google --人工智能为开源存储库生成的维基文档。*
______________________________________________________________________
📖 概述
codewiki mcp 是一个 模型上下文协议 允许AI助手访问的服务器 codewiki.google --为任何GitHub存储库生成全面wiki文档的服务。通过MCP搜索仓库、获取完整文档或提出自然语言问题。
______________________________________________________________________
✨ 特性
| 特性 | 描述 |
|---|---|
| 🔍 搜索仓库 | 查找由codewiki.google索引的存储库 |
| 📄 获取Wiki文档 | 获取任何仓库的完整降价或结构化页面 |
| 💬 提出问题 | 自然语言问答与对话历史 |
| 🧠 NLP回购解决方案 | 自然键入--wink nlp提取关键字并解析为 owner/repo |
| 📡 多个传输 | stdio(默认)、流式HTTP、SSE |
| 🔄 使用回退重试 | 对5xx错误进行指数回退的自动重试 |
| 🐳 Docker支持 | 多阶段阿尔卑斯山建筑 |
| 📊 响应元数据 | 每个响应的字节数和运行时间 |
______________________________________________________________________
🚀 快速开始
使用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 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@latestWindsurf
添加到您的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"]
}
}
}Local development
{
"mcpServers": {
"codewiki-mcp": {
"command": "node",
"args": ["/path/to/codewiki-mcp/dist/cli.js"]
}
}
}______________________________________________________________________
💡 用法
提示您可以在任何兼容MCP的客户端中使用:
codewiki fetch how routing works in Next.jscodewiki search state management librariescodewiki 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" --全额降价; "pages" --结构化JSON |
💬 codewiki_ask_repo
问一个关于存储库的自然语言问题。
| 参数 | 类型 | 必填 | 默认 | 说明 |
|---|---|---|---|---|
repo | string | ✅ | — | 存储库标识符(格式与fetch相同) |
question | string | ✅ | — | 关于回购的问题 |
history | 数组 | -- | [] | 对话历史 [{role, content}] (最多20个) |
______________________________________________________________________
📊 响应格式
✅ Success — Search
{
"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
}
}✅ Success — Fetch (pages mode)
{
"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
}
}✅ Success — Ask
{
"answer": "Fastify uses a plugin-based architecture where...",
"meta": {
"totalBytes": 8500,
"totalElapsedMs": 2300
}
}❌ Error Response
{
"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 APIGoogle批处理执行RPC
codewiki.google使用谷歌的内部 批量执行 RPC格式(不是REST,也不是GraphQL)。客户:
- 使用以下命令构建POST请求
f.req=...身体 - 发送到
/_/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 | 250毫秒 |
| 2 | 500毫秒 |
| 3 | 1000毫秒 |
4xx错误(客户端错误)永远不会重试。
______________________________________________________________________
🖥️ 命令行界面
codewiki-mcp [options]
Options:
--http Streamable HTTP transport
--sse SSE transport
--port Port for HTTP/SSE (default: 3000)
--endpoint 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______________________________________________________________________
❓ 故障排除
Permission Denied
chmod +x ./node_modules/.bin/codewiki-mcpConnection Refused (HTTP/SSE)
# Check if port is in use
lsof -i :3000Timeout Errors
对于大型存储库,请增加超时时间:
CODEWIKI_REQUEST_TIMEOUT=60000 node dist/cli.jsNLP Resolution Fails
如果自然语言输入无法解析,请使用显式格式:
# 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/______________________________________________________________________
🤝 贡献
欢迎投稿!拜托:
- 分叉存储库
- 创建要素分支(
git checkout -b feat/my-feature) - 使用 常规承诺 用于提交消息
- 跑
npm run typecheck && npm run test在提交之前 - 打开拉取请求
______________________________________________________________________
📄 许可证
麻省理工学院 ©codewiki mcp贡献者
