codewiki-mcp 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cli.js +0 -0
- package/package.json +23 -1
- package/.claude/skills/codewiki.md +0 -186
- package/.cursor/mcp.json +0 -9
- package/.dockerignore +0 -10
- package/.github/dependabot.yml +0 -33
- package/.github/workflows/ci.yml +0 -42
- package/.github/workflows/release.yml +0 -36
- package/.releaserc.json +0 -16
- package/CHANGELOG.md +0 -13
- package/Dockerfile +0 -15
- package/src/cli.ts +0 -67
- package/src/index.ts +0 -32
- package/src/lib/batchexecute.ts +0 -72
- package/src/lib/codewikiClient.ts +0 -294
- package/src/lib/config.ts +0 -30
- package/src/lib/errors.ts +0 -57
- package/src/lib/extractKeyword.ts +0 -47
- package/src/lib/repo.ts +0 -70
- package/src/lib/resolveRepo.ts +0 -60
- package/src/schemas.ts +0 -22
- package/src/server.ts +0 -120
- package/src/tools/askRepo.ts +0 -38
- package/src/tools/fetchRepo.ts +0 -74
- package/src/tools/searchRepos.ts +0 -40
- package/tests/batchexecute.test.ts +0 -42
- package/tests/client.test.ts +0 -129
- package/tests/errors.test.ts +0 -122
- package/tests/extractKeyword.test.ts +0 -34
- package/tests/resolveRepo.test.ts +0 -79
- package/tsconfig.json +0 -18
- package/vitest.config.ts +0 -10
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 codewiki-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codewiki-mcp",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"mcpName": "io.github.izzzzzi/codewiki-mcp",
|
|
4
5
|
"description": "MCP server for codewiki.google",
|
|
5
6
|
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
6
8
|
"bin": {
|
|
7
9
|
"codewiki-mcp": "dist/cli.js"
|
|
8
10
|
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mcp",
|
|
18
|
+
"mcp-server",
|
|
19
|
+
"codewiki",
|
|
20
|
+
"documentation",
|
|
21
|
+
"github",
|
|
22
|
+
"ai",
|
|
23
|
+
"model-context-protocol"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/izzzzzi/codewiki-mcp.git"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/izzzzzi/codewiki-mcp",
|
|
9
31
|
"scripts": {
|
|
10
32
|
"build": "tsc -p tsconfig.json",
|
|
11
33
|
"dev": "tsx src/cli.ts",
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: codewiki
|
|
3
|
-
description: Research any open-source repository via codewiki.google — search, fetch wiki docs, ask questions
|
|
4
|
-
tools: ["codewiki_search_repos", "codewiki_fetch_repo", "codewiki_ask_repo"]
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# CodeWiki MCP — Skill Guide
|
|
8
|
-
|
|
9
|
-
## Available Tools
|
|
10
|
-
|
|
11
|
-
### codewiki_search_repos
|
|
12
|
-
Search repositories indexed by codewiki.google.
|
|
13
|
-
|
|
14
|
-
| Parameter | Type | Required | Description |
|
|
15
|
-
|-----------|------|----------|-------------|
|
|
16
|
-
| `query` | string | yes | Search query (library name, keyword, description) |
|
|
17
|
-
| `limit` | number | no | Max results (1-50, default 10) |
|
|
18
|
-
|
|
19
|
-
**Returns**: JSON with `query`, `count`, `items[]` (each with `fullName`, `url`, `description`, `avatarUrl`, `extraScore`), and `meta` (totalBytes, totalElapsedMs).
|
|
20
|
-
|
|
21
|
-
### codewiki_fetch_repo
|
|
22
|
-
Fetch generated wiki content for a repository.
|
|
23
|
-
|
|
24
|
-
| Parameter | Type | Required | Description |
|
|
25
|
-
|-----------|------|----------|-------------|
|
|
26
|
-
| `repo` | string | yes | Repository identifier: `owner/repo`, full GitHub URL, or natural-language query (NLP resolved) |
|
|
27
|
-
| `mode` | string | no | `"aggregate"` (default) — full markdown; `"pages"` — structured JSON per section |
|
|
28
|
-
|
|
29
|
-
**Returns**:
|
|
30
|
-
- **aggregate mode**: Markdown text with preface (repo, commit, canonical URL, response meta)
|
|
31
|
-
- **pages mode**: JSON with `repo`, `commit`, `canonicalUrl`, `pages[]` (title, level, anchor, markdown, diagramCount), and `meta`
|
|
32
|
-
|
|
33
|
-
### codewiki_ask_repo
|
|
34
|
-
Ask a natural-language question about a repository.
|
|
35
|
-
|
|
36
|
-
| Parameter | Type | Required | Description |
|
|
37
|
-
|-----------|------|----------|-------------|
|
|
38
|
-
| `repo` | string | yes | Repository identifier (same formats as fetch) |
|
|
39
|
-
| `question` | string | yes | Natural-language question about the repo |
|
|
40
|
-
| `history` | array | no | Conversation history: `[{role: "user"|"assistant", content: "..."}]` (max 20) |
|
|
41
|
-
|
|
42
|
-
**Returns**: JSON with `answer` (string) and `meta` (totalBytes, totalElapsedMs).
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## Prompt Templates
|
|
47
|
-
|
|
48
|
-
### Study a project's architecture
|
|
49
|
-
```
|
|
50
|
-
1. codewiki_search_repos(query: "<project name>")
|
|
51
|
-
→ find the exact owner/repo
|
|
52
|
-
2. codewiki_fetch_repo(repo: "<owner/repo>", mode: "aggregate")
|
|
53
|
-
→ read the full wiki to understand architecture
|
|
54
|
-
3. codewiki_ask_repo(repo: "<owner/repo>", question: "What are the main architectural patterns and components?")
|
|
55
|
-
→ deep-dive into architecture
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Find how a feature is implemented
|
|
59
|
-
```
|
|
60
|
-
codewiki_ask_repo(
|
|
61
|
-
repo: "<owner/repo>",
|
|
62
|
-
question: "How is <feature X> implemented? Show the key modules and data flow."
|
|
63
|
-
)
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Compare approaches in two repos
|
|
67
|
-
```
|
|
68
|
-
1. codewiki_fetch_repo(repo: "<owner1/repo1>", mode: "pages")
|
|
69
|
-
2. codewiki_fetch_repo(repo: "<owner2/repo2>", mode: "pages")
|
|
70
|
-
3. Compare the architectural approaches, patterns, and trade-offs
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Quick library overview
|
|
74
|
-
```
|
|
75
|
-
1. codewiki_search_repos(query: "<library>")
|
|
76
|
-
→ confirm the right repo
|
|
77
|
-
2. codewiki_fetch_repo(repo: "<owner/repo>", mode: "pages")
|
|
78
|
-
→ get structured sections
|
|
79
|
-
3. Summarize: purpose, key features, getting started, API surface
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Explore a topic across repos
|
|
83
|
-
```
|
|
84
|
-
1. codewiki_search_repos(query: "<topic>", limit: 5)
|
|
85
|
-
→ find top repos for the topic
|
|
86
|
-
2. For each interesting repo:
|
|
87
|
-
codewiki_ask_repo(repo: "<repo>", question: "Summarize the approach to <topic>")
|
|
88
|
-
3. Synthesize findings across repos
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Workflow Chains
|
|
94
|
-
|
|
95
|
-
### Deep Research Chain
|
|
96
|
-
**Goal**: Thorough understanding of a project
|
|
97
|
-
|
|
98
|
-
1. **Search** → `codewiki_search_repos` to find the repo and confirm its full name
|
|
99
|
-
2. **Fetch overview** → `codewiki_fetch_repo(mode: "aggregate")` to read the full wiki
|
|
100
|
-
3. **Ask specific questions** → `codewiki_ask_repo` for deep-dives into specific areas
|
|
101
|
-
4. **Follow up** → Use `history` parameter to maintain context across questions
|
|
102
|
-
|
|
103
|
-
### Comparison Chain
|
|
104
|
-
**Goal**: Compare two or more implementations
|
|
105
|
-
|
|
106
|
-
1. **Fetch all** → `codewiki_fetch_repo(mode: "pages")` for each repo
|
|
107
|
-
2. **Identify patterns** → Extract architectural sections from each
|
|
108
|
-
3. **Ask targeted questions** → `codewiki_ask_repo` about specific differences
|
|
109
|
-
|
|
110
|
-
### Migration Research Chain
|
|
111
|
-
**Goal**: Understand a library for migration
|
|
112
|
-
|
|
113
|
-
1. **Search** → Find source and target libraries
|
|
114
|
-
2. **Fetch both** → Get wiki content for both
|
|
115
|
-
3. **Ask migration questions** → "What are the key API differences between X and Y?"
|
|
116
|
-
4. **Ask compatibility** → "What breaking changes should I watch for?"
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## Error Handling
|
|
121
|
-
|
|
122
|
-
| Error Code | Meaning | Action |
|
|
123
|
-
|------------|---------|--------|
|
|
124
|
-
| `VALIDATION` | Invalid input parameters | Check parameter types and required fields |
|
|
125
|
-
| `RPC_FAIL` | CodeWiki API call failed | Retry with different query; check if repo exists on codewiki.google |
|
|
126
|
-
| `TIMEOUT` | Request timed out | Try again; for large repos, use `mode: "pages"` to get structured data |
|
|
127
|
-
| `NLP_RESOLVE_FAIL` | Could not resolve natural-language input to a repo | Use explicit `owner/repo` format instead |
|
|
128
|
-
|
|
129
|
-
When you receive an error:
|
|
130
|
-
1. Parse the error envelope: `{ error: { code, message, rpcId?, statusCode? } }`
|
|
131
|
-
2. If `RPC_FAIL` with `statusCode: 404` → repo not indexed, suggest searching first
|
|
132
|
-
3. If `TIMEOUT` → simplify query or try mode: "pages" for fetch
|
|
133
|
-
4. If `NLP_RESOLVE_FAIL` → ask user for the exact repo name
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## Conversation History Tips
|
|
138
|
-
|
|
139
|
-
The `history` parameter in `codewiki_ask_repo` enables multi-turn conversations:
|
|
140
|
-
|
|
141
|
-
```json
|
|
142
|
-
{
|
|
143
|
-
"repo": "facebook/react",
|
|
144
|
-
"question": "How does the fiber reconciler differ?",
|
|
145
|
-
"history": [
|
|
146
|
-
{"role": "user", "content": "What is the rendering pipeline?"},
|
|
147
|
-
{"role": "assistant", "content": "React's rendering pipeline consists of..."}
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
**Best practices**:
|
|
153
|
-
- Keep history under 20 entries for optimal performance
|
|
154
|
-
- Include only relevant prior Q&A pairs
|
|
155
|
-
- Summarize long assistant responses in history to save tokens
|
|
156
|
-
- Start a new conversation (no history) when changing topics
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## Examples
|
|
161
|
-
|
|
162
|
-
### Example 1: Quick repo lookup
|
|
163
|
-
**User**: "What does the fastify framework do?"
|
|
164
|
-
```
|
|
165
|
-
codewiki_search_repos(query: "fastify")
|
|
166
|
-
→ finds fastify/fastify
|
|
167
|
-
codewiki_ask_repo(repo: "fastify/fastify", question: "What is Fastify and what are its key features?")
|
|
168
|
-
→ comprehensive answer
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Example 2: Architecture deep-dive
|
|
172
|
-
**User**: "Explain how Next.js handles server-side rendering"
|
|
173
|
-
```
|
|
174
|
-
codewiki_fetch_repo(repo: "vercel/next.js", mode: "aggregate")
|
|
175
|
-
→ full wiki content
|
|
176
|
-
codewiki_ask_repo(repo: "vercel/next.js", question: "How does Next.js implement server-side rendering? Describe the request lifecycle.")
|
|
177
|
-
→ detailed SSR explanation
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Example 3: Library comparison
|
|
181
|
-
**User**: "Compare Express and Fastify"
|
|
182
|
-
```
|
|
183
|
-
codewiki_fetch_repo(repo: "expressjs/express", mode: "pages")
|
|
184
|
-
codewiki_fetch_repo(repo: "fastify/fastify", mode: "pages")
|
|
185
|
-
→ compare architectures, middleware patterns, performance approaches
|
|
186
|
-
```
|
package/.cursor/mcp.json
DELETED
package/.dockerignore
DELETED
package/.github/dependabot.yml
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
version: 2
|
|
2
|
-
|
|
3
|
-
updates:
|
|
4
|
-
- package-ecosystem: npm
|
|
5
|
-
directory: /
|
|
6
|
-
schedule:
|
|
7
|
-
interval: weekly
|
|
8
|
-
day: monday
|
|
9
|
-
open-pull-requests-limit: 10
|
|
10
|
-
labels:
|
|
11
|
-
- dependencies
|
|
12
|
-
commit-message:
|
|
13
|
-
prefix: "chore(deps):"
|
|
14
|
-
groups:
|
|
15
|
-
dev-dependencies:
|
|
16
|
-
dependency-type: development
|
|
17
|
-
update-types:
|
|
18
|
-
- minor
|
|
19
|
-
- patch
|
|
20
|
-
production-dependencies:
|
|
21
|
-
dependency-type: production
|
|
22
|
-
update-types:
|
|
23
|
-
- patch
|
|
24
|
-
|
|
25
|
-
- package-ecosystem: github-actions
|
|
26
|
-
directory: /
|
|
27
|
-
schedule:
|
|
28
|
-
interval: weekly
|
|
29
|
-
day: monday
|
|
30
|
-
labels:
|
|
31
|
-
- ci
|
|
32
|
-
commit-message:
|
|
33
|
-
prefix: "ci:"
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
permissions:
|
|
10
|
-
contents: read
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
test:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
strategy:
|
|
16
|
-
matrix:
|
|
17
|
-
node-version: [18, 20, 22]
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v6
|
|
20
|
-
|
|
21
|
-
- uses: actions/setup-node@v6
|
|
22
|
-
with:
|
|
23
|
-
node-version: ${{ matrix.node-version }}
|
|
24
|
-
cache: npm
|
|
25
|
-
|
|
26
|
-
- run: npm ci
|
|
27
|
-
- run: npm run typecheck
|
|
28
|
-
- run: npm run build
|
|
29
|
-
- run: npm run test
|
|
30
|
-
|
|
31
|
-
docker:
|
|
32
|
-
runs-on: ubuntu-latest
|
|
33
|
-
needs: test
|
|
34
|
-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
35
|
-
steps:
|
|
36
|
-
- uses: actions/checkout@v6
|
|
37
|
-
|
|
38
|
-
- name: Build Docker image
|
|
39
|
-
run: docker build -t codewiki-mcp .
|
|
40
|
-
|
|
41
|
-
- name: Verify CLI starts
|
|
42
|
-
run: docker run --rm codewiki-mcp --help
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
permissions:
|
|
8
|
-
contents: write
|
|
9
|
-
issues: write
|
|
10
|
-
pull-requests: write
|
|
11
|
-
id-token: write
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
release:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
steps:
|
|
17
|
-
- uses: actions/checkout@v6
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0
|
|
20
|
-
persist-credentials: false
|
|
21
|
-
|
|
22
|
-
- uses: actions/setup-node@v6
|
|
23
|
-
with:
|
|
24
|
-
node-version: 22
|
|
25
|
-
cache: npm
|
|
26
|
-
|
|
27
|
-
- run: npm ci
|
|
28
|
-
- run: npm run typecheck
|
|
29
|
-
- run: npm run build
|
|
30
|
-
- run: npm run test
|
|
31
|
-
|
|
32
|
-
- name: Semantic Release
|
|
33
|
-
env:
|
|
34
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
-
run: npx semantic-release
|
package/.releaserc.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": ["main"],
|
|
3
|
-
"plugins": [
|
|
4
|
-
"@semantic-release/commit-analyzer",
|
|
5
|
-
"@semantic-release/release-notes-generator",
|
|
6
|
-
"@semantic-release/changelog",
|
|
7
|
-
["@semantic-release/npm", {
|
|
8
|
-
"npmPublish": true
|
|
9
|
-
}],
|
|
10
|
-
["@semantic-release/git", {
|
|
11
|
-
"assets": ["CHANGELOG.md", "package.json", "package-lock.json"],
|
|
12
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
13
|
-
}],
|
|
14
|
-
"@semantic-release/github"
|
|
15
|
-
]
|
|
16
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
## [1.0.1](https://github.com/izzzzzi/codewiki-mcp/compare/v1.0.0...v1.0.1) (2026-02-16)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* **docs:** correct GitHub owner in badge URLs and clone links ([dbcaa48](https://github.com/izzzzzi/codewiki-mcp/commit/dbcaa48a8b3ebc99274fa8919ff1ee10ef89d4ac))
|
|
7
|
-
|
|
8
|
-
# 1.0.0 (2026-02-16)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Features
|
|
12
|
-
|
|
13
|
-
* codewiki-mcp v0.2.0 — full MCP server for codewiki.google ([4f4dec7](https://github.com/izzzzzi/codewiki-mcp/commit/4f4dec74e48821e8fe8193b73341fcad1e61449f))
|
package/Dockerfile
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
FROM node:22-alpine AS builder
|
|
2
|
-
WORKDIR /app
|
|
3
|
-
COPY package.json package-lock.json ./
|
|
4
|
-
RUN npm ci
|
|
5
|
-
COPY tsconfig.json ./
|
|
6
|
-
COPY src/ src/
|
|
7
|
-
RUN npm run build
|
|
8
|
-
|
|
9
|
-
FROM node:22-alpine
|
|
10
|
-
WORKDIR /app
|
|
11
|
-
COPY --from=builder /app/package.json /app/package-lock.json ./
|
|
12
|
-
RUN npm ci --omit=dev
|
|
13
|
-
COPY --from=builder /app/dist/ dist/
|
|
14
|
-
EXPOSE 3000
|
|
15
|
-
ENTRYPOINT ["node", "dist/cli.js"]
|
package/src/cli.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { parseArgs } from 'node:util'
|
|
4
|
-
import { loadConfig } from './lib/config.js'
|
|
5
|
-
import { createMcpServer, startServer, stopServer } from './server.js'
|
|
6
|
-
|
|
7
|
-
const HELP = `
|
|
8
|
-
codewiki-mcp — MCP server for codewiki.google
|
|
9
|
-
|
|
10
|
-
Usage:
|
|
11
|
-
codewiki-mcp Start with stdio transport (default)
|
|
12
|
-
codewiki-mcp --http Start with Streamable HTTP transport
|
|
13
|
-
codewiki-mcp --sse Start with SSE transport
|
|
14
|
-
|
|
15
|
-
Options:
|
|
16
|
-
--http Use Streamable HTTP transport
|
|
17
|
-
--sse Use SSE transport
|
|
18
|
-
--port <number> Port for HTTP/SSE (default: 3000)
|
|
19
|
-
--endpoint <str> URL endpoint (default: /mcp)
|
|
20
|
-
--help Show this help message
|
|
21
|
-
|
|
22
|
-
Environment variables:
|
|
23
|
-
CODEWIKI_BASE_URL Base URL (default: https://codewiki.google)
|
|
24
|
-
CODEWIKI_REQUEST_TIMEOUT Request timeout in ms (default: 30000)
|
|
25
|
-
CODEWIKI_MAX_RETRIES Max retries (default: 3)
|
|
26
|
-
CODEWIKI_RETRY_DELAY Base retry delay in ms (default: 250)
|
|
27
|
-
GITHUB_TOKEN GitHub token for NLP repo resolution
|
|
28
|
-
`.trim()
|
|
29
|
-
|
|
30
|
-
async function main(): Promise<void> {
|
|
31
|
-
const { values } = parseArgs({
|
|
32
|
-
options: {
|
|
33
|
-
http: { type: 'boolean', default: false },
|
|
34
|
-
sse: { type: 'boolean', default: false },
|
|
35
|
-
port: { type: 'string', default: '3000' },
|
|
36
|
-
endpoint: { type: 'string', default: '/mcp' },
|
|
37
|
-
help: { type: 'boolean', short: 'h', default: false },
|
|
38
|
-
},
|
|
39
|
-
strict: true,
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
if (values.help) {
|
|
43
|
-
console.log(HELP)
|
|
44
|
-
process.exit(0)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const transport = values.http ? 'http' : values.sse ? 'sse' : 'stdio'
|
|
48
|
-
const port = Number.parseInt(values.port!, 10) || 3000
|
|
49
|
-
const endpoint = values.endpoint!
|
|
50
|
-
|
|
51
|
-
const config = loadConfig()
|
|
52
|
-
const mcp = createMcpServer(config)
|
|
53
|
-
|
|
54
|
-
const shutdown = async () => {
|
|
55
|
-
await stopServer()
|
|
56
|
-
process.exit(0)
|
|
57
|
-
}
|
|
58
|
-
process.on('SIGTERM', shutdown)
|
|
59
|
-
process.on('SIGINT', shutdown)
|
|
60
|
-
|
|
61
|
-
await startServer(mcp, { transport, port, endpoint })
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
main().catch((error) => {
|
|
65
|
-
console.error(error)
|
|
66
|
-
process.exit(1)
|
|
67
|
-
})
|
package/src/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Library re-exports
|
|
2
|
-
export { CodeWikiClient } from './lib/codewikiClient.js'
|
|
3
|
-
export type {
|
|
4
|
-
CodeWikiClientOptions,
|
|
5
|
-
SearchRepoResult,
|
|
6
|
-
WikiSection,
|
|
7
|
-
FetchRepositoryResult,
|
|
8
|
-
AskHistoryItem,
|
|
9
|
-
ResponseMeta,
|
|
10
|
-
WithMeta,
|
|
11
|
-
} from './lib/codewikiClient.js'
|
|
12
|
-
|
|
13
|
-
export { CodeWikiError, formatMcpError } from './lib/errors.js'
|
|
14
|
-
export type { ErrorCode, ErrorEnvelope } from './lib/errors.js'
|
|
15
|
-
|
|
16
|
-
export { loadConfig } from './lib/config.js'
|
|
17
|
-
export type { CodeWikiConfig } from './lib/config.js'
|
|
18
|
-
|
|
19
|
-
export { normalizeRepoInput, resolveRepoInput } from './lib/repo.js'
|
|
20
|
-
export type { NormalizedRepo } from './lib/repo.js'
|
|
21
|
-
|
|
22
|
-
export { extractKeyword } from './lib/extractKeyword.js'
|
|
23
|
-
export { resolveRepoFromGitHub } from './lib/resolveRepo.js'
|
|
24
|
-
|
|
25
|
-
export { createMcpServer, startServer, stopServer } from './server.js'
|
|
26
|
-
export type { ServerOptions } from './server.js'
|
|
27
|
-
|
|
28
|
-
export { SearchReposInput, FetchRepoInput, AskRepoInput } from './schemas.js'
|
|
29
|
-
|
|
30
|
-
export { registerSearchReposTool } from './tools/searchRepos.js'
|
|
31
|
-
export { registerFetchRepoTool } from './tools/fetchRepo.js'
|
|
32
|
-
export { registerAskRepoTool } from './tools/askRepo.js'
|
package/src/lib/batchexecute.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface WrbFrame {
|
|
2
|
-
rpcId: string
|
|
3
|
-
payload: unknown
|
|
4
|
-
rawPayload: unknown
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const XSSI_PREFIX = ")]}'"
|
|
8
|
-
|
|
9
|
-
function stripXssiPrefix(text: string): string {
|
|
10
|
-
const trimmed = text.trimStart()
|
|
11
|
-
if (trimmed.startsWith(XSSI_PREFIX)) {
|
|
12
|
-
return trimmed.slice(XSSI_PREFIX.length).trimStart()
|
|
13
|
-
}
|
|
14
|
-
return text
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function safeJsonParse(input: string): unknown | undefined {
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(input)
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return undefined
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function collectWrbFrames(node: unknown, out: WrbFrame[]): void {
|
|
27
|
-
if (!Array.isArray(node)) {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (node.length >= 3 && node[0] === 'wrb.fr' && typeof node[1] === 'string') {
|
|
32
|
-
const rpcId = node[1]
|
|
33
|
-
const rawPayload = node[2]
|
|
34
|
-
const payload = typeof rawPayload === 'string'
|
|
35
|
-
? (safeJsonParse(rawPayload) ?? rawPayload)
|
|
36
|
-
: rawPayload
|
|
37
|
-
out.push({ rpcId, payload, rawPayload })
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
for (const child of node) {
|
|
41
|
-
collectWrbFrames(child, out)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function extractWrbFrames(responseText: string): WrbFrame[] {
|
|
46
|
-
const body = stripXssiPrefix(responseText)
|
|
47
|
-
const frames: WrbFrame[] = []
|
|
48
|
-
|
|
49
|
-
for (const rawLine of body.split(/\r?\n/)) {
|
|
50
|
-
const line = rawLine.trim()
|
|
51
|
-
if (!line.startsWith('[') || !line.endsWith(']')) {
|
|
52
|
-
continue
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const parsed = safeJsonParse(line)
|
|
56
|
-
if (parsed !== undefined) {
|
|
57
|
-
collectWrbFrames(parsed, frames)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (frames.length === 0) {
|
|
62
|
-
throw new Error('No wrb.fr frames found in batchexecute response')
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return frames
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function extractRpcPayload(responseText: string, rpcId: string): unknown {
|
|
69
|
-
const frames = extractWrbFrames(responseText)
|
|
70
|
-
const match = frames.find(frame => frame.rpcId === rpcId) ?? frames[0]
|
|
71
|
-
return match.payload
|
|
72
|
-
}
|