@j0hanz/code-review-analyst-mcp 1.1.0 → 1.2.1
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/README.md +203 -193
- package/dist/index.js +18 -15
- package/dist/instructions.md +83 -58
- package/dist/lib/context-budget.d.ts +8 -0
- package/dist/lib/context-budget.js +30 -0
- package/dist/lib/diff-budget.d.ts +3 -1
- package/dist/lib/diff-budget.js +16 -19
- package/dist/lib/diff-parser.d.ts +34 -0
- package/dist/lib/diff-parser.js +114 -0
- package/dist/lib/env-config.d.ts +5 -0
- package/dist/lib/env-config.js +24 -0
- package/dist/lib/errors.d.ts +1 -0
- package/dist/lib/errors.js +9 -6
- package/dist/lib/gemini-schema.d.ts +3 -1
- package/dist/lib/gemini-schema.js +18 -17
- package/dist/lib/gemini.d.ts +1 -0
- package/dist/lib/gemini.js +220 -112
- package/dist/lib/model-config.d.ts +17 -0
- package/dist/lib/model-config.js +19 -0
- package/dist/lib/tool-factory.d.ts +22 -8
- package/dist/lib/tool-factory.js +302 -67
- package/dist/lib/tool-response.d.ts +9 -2
- package/dist/lib/tool-response.js +29 -14
- package/dist/lib/types.d.ts +8 -3
- package/dist/prompts/index.js +35 -15
- package/dist/resources/index.js +10 -9
- package/dist/schemas/inputs.d.ts +27 -15
- package/dist/schemas/inputs.js +59 -21
- package/dist/schemas/outputs.d.ts +130 -7
- package/dist/schemas/outputs.js +170 -40
- package/dist/server.d.ts +5 -1
- package/dist/server.js +32 -24
- package/dist/tools/analyze-pr-impact.d.ts +2 -0
- package/dist/tools/analyze-pr-impact.js +46 -0
- package/dist/tools/generate-review-summary.d.ts +2 -0
- package/dist/tools/generate-review-summary.js +67 -0
- package/dist/tools/generate-test-plan.d.ts +2 -0
- package/dist/tools/generate-test-plan.js +56 -0
- package/dist/tools/index.js +10 -6
- package/dist/tools/inspect-code-quality.d.ts +4 -0
- package/dist/tools/inspect-code-quality.js +111 -0
- package/dist/tools/suggest-search-replace.d.ts +2 -0
- package/dist/tools/suggest-search-replace.js +49 -0
- package/package.json +3 -2
- package/dist/tools/review-diff.d.ts +0 -2
- package/dist/tools/review-diff.js +0 -42
- package/dist/tools/risk-score.d.ts +0 -2
- package/dist/tools/risk-score.js +0 -34
- package/dist/tools/suggest-patch.d.ts +0 -2
- package/dist/tools/suggest-patch.js +0 -35
package/README.md
CHANGED
|
@@ -6,23 +6,22 @@
|
|
|
6
6
|
|
|
7
7
|
[](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D&quality=insiders) [](https://vs-open.link/mcp-install?%7B%22name%22%3A%22code-review-analyst%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D)
|
|
8
8
|
|
|
9
|
-
[](https://cursor.com/en/install-mcp?name=
|
|
9
|
+
[](https://cursor.com/en/install-mcp?name=code-review-analyst&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovY29kZS1yZXZpZXctYW5hbHlzdC1tY3BAbGF0ZXN0Il19)
|
|
10
10
|
|
|
11
11
|
Gemini-powered MCP server for pull request analysis with structured outputs for findings, release risk, and focused patch suggestions.
|
|
12
12
|
|
|
13
13
|
## Overview
|
|
14
14
|
|
|
15
|
-
This server
|
|
15
|
+
This server accepts unified diffs and returns structured JSON results — findings with severity, impact categories, merge risk, test plans, and verbatim search/replace fixes. It uses Gemini Thinking models (Flash for fast tools, Pro for deep analysis) and runs over **stdio transport**.
|
|
16
16
|
|
|
17
17
|
## Key Features
|
|
18
18
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
- Docker image available via GitHub Container Registry.
|
|
19
|
+
- **Impact Analysis** — Objective severity scoring, breaking change detection, and rollback complexity assessment.
|
|
20
|
+
- **Review Summary** — Concise PR digest with merge recommendation and change statistics.
|
|
21
|
+
- **Deep Code Inspection** — Pro model with 16K thinking budget for context-aware analysis using full file contents.
|
|
22
|
+
- **Search & Replace Fixes** — Verbatim, copy-paste-ready code fixes tied to specific findings.
|
|
23
|
+
- **Test Plan Generation** — Systematic test case generation with priority ranking and pseudocode.
|
|
24
|
+
- **Async Task Support** — All tools support MCP task lifecycle with progress notifications.
|
|
26
25
|
|
|
27
26
|
## Requirements
|
|
28
27
|
|
|
@@ -32,8 +31,6 @@ This server runs over **stdio transport** and exposes three review-focused tools
|
|
|
32
31
|
|
|
33
32
|
## Quick Start
|
|
34
33
|
|
|
35
|
-
Standard config for most MCP clients:
|
|
36
|
-
|
|
37
34
|
```json
|
|
38
35
|
{
|
|
39
36
|
"mcpServers": {
|
|
@@ -48,18 +45,14 @@ Standard config for most MCP clients:
|
|
|
48
45
|
}
|
|
49
46
|
```
|
|
50
47
|
|
|
51
|
-
> [!TIP]
|
|
52
|
-
> For local development, build and run directly via `node dist/index.js` after `npm run build`.
|
|
53
|
-
|
|
54
48
|
## Client Configuration
|
|
55
49
|
|
|
56
50
|
<details>
|
|
57
|
-
<summary><b>
|
|
51
|
+
<summary><b>VS Code / VS Code Insiders</b></summary>
|
|
58
52
|
|
|
59
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D)
|
|
60
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D&quality=insiders)
|
|
53
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=Code+Review+Analyst&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D&quality=insiders)
|
|
61
54
|
|
|
62
|
-
`.vscode/mcp.json
|
|
55
|
+
Add to `.vscode/mcp.json`:
|
|
63
56
|
|
|
64
57
|
```json
|
|
65
58
|
{
|
|
@@ -75,22 +68,20 @@ Standard config for most MCP clients:
|
|
|
75
68
|
}
|
|
76
69
|
```
|
|
77
70
|
|
|
78
|
-
CLI
|
|
71
|
+
Or via CLI:
|
|
79
72
|
|
|
80
73
|
```bash
|
|
81
74
|
code --add-mcp '{"name":"code-review-analyst","command":"npx","args":["-y","@j0hanz/code-review-analyst-mcp@latest"]}'
|
|
82
75
|
```
|
|
83
76
|
|
|
84
|
-
For more info, see [VS Code MCP docs](https://code.visualstudio.com/docs/copilot/customization/mcp-servers).
|
|
85
|
-
|
|
86
77
|
</details>
|
|
87
78
|
|
|
88
79
|
<details>
|
|
89
|
-
<summary><b>
|
|
80
|
+
<summary><b>Cursor</b></summary>
|
|
90
81
|
|
|
91
|
-
[](https://cursor.com/en/install-mcp?name=
|
|
82
|
+
[](https://cursor.com/en/install-mcp?name=code-review-analyst&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovY29kZS1yZXZpZXctYW5hbHlzdC1tY3BAbGF0ZXN0Il19)
|
|
92
83
|
|
|
93
|
-
`~/.cursor/mcp.json
|
|
84
|
+
Add to `~/.cursor/mcp.json`:
|
|
94
85
|
|
|
95
86
|
```json
|
|
96
87
|
{
|
|
@@ -106,14 +97,21 @@ For more info, see [VS Code MCP docs](https://code.visualstudio.com/docs/copilot
|
|
|
106
97
|
}
|
|
107
98
|
```
|
|
108
99
|
|
|
109
|
-
|
|
100
|
+
</details>
|
|
101
|
+
|
|
102
|
+
<details>
|
|
103
|
+
<summary><b>Visual Studio</b></summary>
|
|
104
|
+
|
|
105
|
+
[](https://vs-open.link/mcp-install?%7B%22name%22%3A%22code-review-analyst%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fcode-review-analyst-mcp%40latest%22%5D%7D)
|
|
106
|
+
|
|
107
|
+
For more info, see [Visual Studio MCP docs](https://learn.microsoft.com/en-us/visualstudio/ide/mcp-servers).
|
|
110
108
|
|
|
111
109
|
</details>
|
|
112
110
|
|
|
113
111
|
<details>
|
|
114
|
-
<summary><b>
|
|
112
|
+
<summary><b>Claude Desktop</b></summary>
|
|
115
113
|
|
|
116
|
-
`claude_desktop_config.json
|
|
114
|
+
Add to `claude_desktop_config.json`:
|
|
117
115
|
|
|
118
116
|
```json
|
|
119
117
|
{
|
|
@@ -129,25 +127,25 @@ For more info, see [Cursor MCP docs](https://cursor.com/docs/context/mcp).
|
|
|
129
127
|
}
|
|
130
128
|
```
|
|
131
129
|
|
|
132
|
-
For more info, see [Claude Desktop MCP docs](https://modelcontextprotocol.io/
|
|
130
|
+
For more info, see [Claude Desktop MCP docs](https://modelcontextprotocol.io/quickstart/user).
|
|
133
131
|
|
|
134
132
|
</details>
|
|
135
133
|
|
|
136
134
|
<details>
|
|
137
|
-
<summary><b>
|
|
135
|
+
<summary><b>Claude Code</b></summary>
|
|
138
136
|
|
|
139
137
|
```bash
|
|
140
138
|
claude mcp add code-review-analyst -- npx -y @j0hanz/code-review-analyst-mcp@latest
|
|
141
139
|
```
|
|
142
140
|
|
|
143
|
-
For more info, see [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp).
|
|
141
|
+
For more info, see [Claude Code MCP docs](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp).
|
|
144
142
|
|
|
145
143
|
</details>
|
|
146
144
|
|
|
147
145
|
<details>
|
|
148
|
-
<summary><b>
|
|
146
|
+
<summary><b>Windsurf</b></summary>
|
|
149
147
|
|
|
150
|
-
MCP config:
|
|
148
|
+
Add to MCP config:
|
|
151
149
|
|
|
152
150
|
```json
|
|
153
151
|
{
|
|
@@ -163,25 +161,25 @@ MCP config:
|
|
|
163
161
|
}
|
|
164
162
|
```
|
|
165
163
|
|
|
166
|
-
For more info, see [Windsurf MCP docs](https://docs.windsurf.com/windsurf/
|
|
164
|
+
For more info, see [Windsurf MCP docs](https://docs.windsurf.com/windsurf/mcp).
|
|
167
165
|
|
|
168
166
|
</details>
|
|
169
167
|
|
|
170
168
|
<details>
|
|
171
|
-
<summary><b>
|
|
169
|
+
<summary><b>Amp</b></summary>
|
|
172
170
|
|
|
173
171
|
```bash
|
|
174
172
|
amp mcp add code-review-analyst -- npx -y @j0hanz/code-review-analyst-mcp@latest
|
|
175
173
|
```
|
|
176
174
|
|
|
177
|
-
For more info, see [Amp MCP docs](https://
|
|
175
|
+
For more info, see [Amp MCP docs](https://docs.amp.dev/mcp).
|
|
178
176
|
|
|
179
177
|
</details>
|
|
180
178
|
|
|
181
179
|
<details>
|
|
182
|
-
<summary><b>
|
|
180
|
+
<summary><b>Cline</b></summary>
|
|
183
181
|
|
|
184
|
-
`cline_mcp_settings.json
|
|
182
|
+
Add to `cline_mcp_settings.json`:
|
|
185
183
|
|
|
186
184
|
```json
|
|
187
185
|
{
|
|
@@ -197,32 +195,61 @@ For more info, see [Amp MCP docs](https://ampcode.com/manual).
|
|
|
197
195
|
}
|
|
198
196
|
```
|
|
199
197
|
|
|
200
|
-
For more info, see [Cline MCP docs](https://docs.cline.bot/mcp/
|
|
198
|
+
For more info, see [Cline MCP docs](https://docs.cline.bot/mcp-servers/configuring-mcp-servers).
|
|
201
199
|
|
|
202
200
|
</details>
|
|
203
201
|
|
|
204
202
|
<details>
|
|
205
|
-
<summary><b>
|
|
203
|
+
<summary><b>Zed</b></summary>
|
|
206
204
|
|
|
207
|
-
`settings.json
|
|
205
|
+
Add to Zed `settings.json`:
|
|
208
206
|
|
|
209
207
|
```json
|
|
210
208
|
{
|
|
211
209
|
"context_servers": {
|
|
212
210
|
"code-review-analyst": {
|
|
213
|
-
"command":
|
|
214
|
-
|
|
211
|
+
"command": {
|
|
212
|
+
"path": "npx",
|
|
213
|
+
"args": ["-y", "@j0hanz/code-review-analyst-mcp@latest"],
|
|
214
|
+
"env": {
|
|
215
|
+
"GEMINI_API_KEY": "YOUR_API_KEY"
|
|
216
|
+
}
|
|
217
|
+
}
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
220
|
}
|
|
218
221
|
```
|
|
219
222
|
|
|
220
|
-
For more info, see [Zed MCP docs](https://zed.dev/docs/
|
|
223
|
+
For more info, see [Zed MCP docs](https://zed.dev/docs/assistant/model-context-protocol).
|
|
221
224
|
|
|
222
225
|
</details>
|
|
223
226
|
|
|
224
227
|
<details>
|
|
225
|
-
<summary><b>
|
|
228
|
+
<summary><b>Augment</b></summary>
|
|
229
|
+
|
|
230
|
+
Add to `settings.json`:
|
|
231
|
+
|
|
232
|
+
```json
|
|
233
|
+
{
|
|
234
|
+
"augment.advanced": {
|
|
235
|
+
"mcpServers": [
|
|
236
|
+
{
|
|
237
|
+
"name": "code-review-analyst",
|
|
238
|
+
"command": "npx",
|
|
239
|
+
"args": ["-y", "@j0hanz/code-review-analyst-mcp@latest"],
|
|
240
|
+
"env": {
|
|
241
|
+
"GEMINI_API_KEY": "YOUR_API_KEY"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
</details>
|
|
250
|
+
|
|
251
|
+
<details>
|
|
252
|
+
<summary><b>Docker</b></summary>
|
|
226
253
|
|
|
227
254
|
```json
|
|
228
255
|
{
|
|
@@ -234,7 +261,7 @@ For more info, see [Zed MCP docs](https://zed.dev/docs/ai/mcp).
|
|
|
234
261
|
"-i",
|
|
235
262
|
"--rm",
|
|
236
263
|
"-e",
|
|
237
|
-
"GEMINI_API_KEY",
|
|
264
|
+
"GEMINI_API_KEY=YOUR_API_KEY",
|
|
238
265
|
"ghcr.io/j0hanz/code-review-analyst-mcp:latest"
|
|
239
266
|
]
|
|
240
267
|
}
|
|
@@ -242,212 +269,195 @@ For more info, see [Zed MCP docs](https://zed.dev/docs/ai/mcp).
|
|
|
242
269
|
}
|
|
243
270
|
```
|
|
244
271
|
|
|
245
|
-
|
|
246
|
-
|
|
272
|
+
Or build locally:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
docker build -t code-review-analyst-mcp .
|
|
276
|
+
```
|
|
247
277
|
|
|
248
278
|
</details>
|
|
249
279
|
|
|
250
|
-
##
|
|
280
|
+
## Tools
|
|
251
281
|
|
|
252
|
-
###
|
|
282
|
+
### `analyze_pr_impact`
|
|
253
283
|
|
|
254
|
-
|
|
284
|
+
Assess the impact and risk of a pull request diff using the Flash model.
|
|
255
285
|
|
|
256
|
-
|
|
286
|
+
| Parameter | Type | Required | Description |
|
|
287
|
+
| ------------ | -------- | -------- | ---------------------------------------- |
|
|
288
|
+
| `diff` | `string` | Yes | Unified diff text. |
|
|
289
|
+
| `repository` | `string` | Yes | Repository identifier (e.g. `org/repo`). |
|
|
290
|
+
| `language` | `string` | No | Primary language hint. |
|
|
257
291
|
|
|
258
|
-
|
|
259
|
-
| ------------- | ---------- | -------- | ------------------------------------------------- | ---------------------------------------------------- |
|
|
260
|
-
| `diff` | `string` | Yes | — | Unified diff text (`10..400000` chars schema limit). |
|
|
261
|
-
| `repository` | `string` | Yes | — | Repository identifier (example: `org/repo`). |
|
|
262
|
-
| `language` | `string` | No | `not specified` | Primary language hint for analysis. |
|
|
263
|
-
| `focusAreas` | `string[]` | No | `security, correctness, regressions, performance` | Optional review priorities (`1..12` items). |
|
|
264
|
-
| `maxFindings` | `integer` | No | `10` | Max findings returned (`1..25`). |
|
|
292
|
+
**Returns:** `severity` (low/medium/high/critical), `categories[]`, `breakingChanges[]`, `affectedAreas[]`, `rollbackComplexity`, `summary`.
|
|
265
293
|
|
|
266
|
-
|
|
294
|
+
### `generate_review_summary`
|
|
267
295
|
|
|
268
|
-
|
|
296
|
+
Summarize a pull request diff and assess high-level risk using the Flash model.
|
|
269
297
|
|
|
270
|
-
|
|
298
|
+
| Parameter | Type | Required | Description |
|
|
299
|
+
| ------------ | -------- | -------- | ---------------------------------------- |
|
|
300
|
+
| `diff` | `string` | Yes | Unified diff text. |
|
|
301
|
+
| `repository` | `string` | Yes | Repository identifier (e.g. `org/repo`). |
|
|
302
|
+
| `language` | `string` | No | Primary language hint. |
|
|
271
303
|
|
|
272
|
-
|
|
273
|
-
{
|
|
274
|
-
"ok": true,
|
|
275
|
-
"result": {
|
|
276
|
-
"summary": "One high-risk auth-path change without null guards.",
|
|
277
|
-
"overallRisk": "high",
|
|
278
|
-
"findings": [
|
|
279
|
-
{
|
|
280
|
-
"severity": "high",
|
|
281
|
-
"file": "src/auth.ts",
|
|
282
|
-
"line": 42,
|
|
283
|
-
"title": "Missing null check",
|
|
284
|
-
"explanation": "Null response can throw and break login.",
|
|
285
|
-
"recommendation": "Guard for null before property access."
|
|
286
|
-
}
|
|
287
|
-
],
|
|
288
|
-
"testsNeeded": ["Add auth null-path regression test"]
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
#### `risk_score`
|
|
304
|
+
**Returns:** `summary`, `overallRisk` (low/medium/high), `keyChanges[]`, `recommendation`, `stats` (filesChanged, linesAdded, linesRemoved).
|
|
294
305
|
|
|
295
|
-
|
|
306
|
+
### `inspect_code_quality`
|
|
296
307
|
|
|
297
|
-
|
|
298
|
-
| ----------------------- | ----------------------------- | -------- | -------- | ---------------------------------------------------- |
|
|
299
|
-
| `diff` | `string` | Yes | — | Unified diff text (`10..400000` chars schema limit). |
|
|
300
|
-
| `deploymentCriticality` | `"low" \| "medium" \| "high"` | No | `medium` | Sensitivity of target deployment. |
|
|
308
|
+
Deep-dive code review with optional file context using the Pro model with thinking (16K token budget).
|
|
301
309
|
|
|
302
|
-
|
|
310
|
+
| Parameter | Type | Required | Description |
|
|
311
|
+
| ------------- | ---------- | -------- | --------------------------------------------------- |
|
|
312
|
+
| `diff` | `string` | Yes | Unified diff text. |
|
|
313
|
+
| `repository` | `string` | Yes | Repository identifier (e.g. `org/repo`). |
|
|
314
|
+
| `language` | `string` | No | Primary language hint. |
|
|
315
|
+
| `focusAreas` | `string[]` | No | Areas to inspect: security, correctness, etc. |
|
|
316
|
+
| `maxFindings` | `number` | No | Maximum findings to return (1-25). |
|
|
317
|
+
| `files` | `object[]` | No | Full file contents (`path`, `content`) for context. |
|
|
303
318
|
|
|
304
|
-
|
|
319
|
+
**Returns:** `summary`, `overallRisk` (low/medium/high/critical), `findings[]` (severity, file, line, title, explanation, recommendation), `testsNeeded[]`, `contextualInsights[]`.
|
|
305
320
|
|
|
306
|
-
|
|
321
|
+
> [!NOTE]
|
|
322
|
+
> Enforces `MAX_CONTEXT_CHARS` (default 500,000) on combined diff + files size. Expect 60-120s latency due to deep thinking.
|
|
307
323
|
|
|
308
|
-
|
|
324
|
+
### `suggest_search_replace`
|
|
309
325
|
|
|
310
|
-
|
|
311
|
-
| ---------------- | ---------------------------------------- | -------- | ---------- | ------------------------------------------------ |
|
|
312
|
-
| `diff` | `string` | Yes | — | Unified diff text containing the issue context. |
|
|
313
|
-
| `findingTitle` | `string` | Yes | — | Short finding title (`3..160` chars). |
|
|
314
|
-
| `findingDetails` | `string` | Yes | — | Detailed finding explanation (`10..3000` chars). |
|
|
315
|
-
| `patchStyle` | `"minimal" \| "balanced" \| "defensive"` | No | `balanced` | Desired patch breadth. |
|
|
326
|
+
Generate verbatim search-and-replace blocks to fix a specific finding using the Pro model with thinking.
|
|
316
327
|
|
|
317
|
-
|
|
328
|
+
| Parameter | Type | Required | Description |
|
|
329
|
+
| ---------------- | -------- | -------- | ---------------------------------------- |
|
|
330
|
+
| `diff` | `string` | Yes | Unified diff that contains the issue. |
|
|
331
|
+
| `findingTitle` | `string` | Yes | Short title of the finding to fix. |
|
|
332
|
+
| `findingDetails` | `string` | Yes | Detailed explanation of the bug or risk. |
|
|
318
333
|
|
|
319
|
-
|
|
334
|
+
**Returns:** `summary`, `blocks[]` (file, search, replace, explanation), `validationChecklist[]`.
|
|
320
335
|
|
|
321
|
-
###
|
|
336
|
+
### `generate_test_plan`
|
|
322
337
|
|
|
323
|
-
|
|
324
|
-
| ------------------------- | --------------------- | --------------- | -------------------------------------------- |
|
|
325
|
-
| `internal://instructions` | `server-instructions` | `text/markdown` | In-repo usage guide for tools and workflows. |
|
|
338
|
+
Create a test plan covering the changes in the diff using the Flash model with thinking (8K token budget).
|
|
326
339
|
|
|
327
|
-
|
|
340
|
+
| Parameter | Type | Required | Description |
|
|
341
|
+
| --------------- | -------- | -------- | ------------------------------------------- |
|
|
342
|
+
| `diff` | `string` | Yes | Unified diff to generate tests for. |
|
|
343
|
+
| `repository` | `string` | Yes | Repository identifier (e.g. `org/repo`). |
|
|
344
|
+
| `language` | `string` | No | Primary language hint. |
|
|
345
|
+
| `testFramework` | `string` | No | Test framework (e.g. jest, vitest, pytest). |
|
|
346
|
+
| `maxTestCases` | `number` | No | Maximum test cases to return (1-30). |
|
|
328
347
|
|
|
329
|
-
|
|
330
|
-
| ---------- | ---------------------------------- | --------- |
|
|
331
|
-
| `get-help` | Returns server usage instructions. | None |
|
|
348
|
+
**Returns:** `summary`, `testCases[]` (name, type, file, description, pseudoCode, priority), `coverageSummary`.
|
|
332
349
|
|
|
333
|
-
|
|
350
|
+
## Resources
|
|
334
351
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
- Task storage uses in-memory task store (`InMemoryTaskStore`).
|
|
352
|
+
| URI | Type | Description |
|
|
353
|
+
| ------------------------- | --------------- | -------------------------- |
|
|
354
|
+
| `internal://instructions` | `text/markdown` | Server usage instructions. |
|
|
339
355
|
|
|
340
|
-
##
|
|
356
|
+
## Prompts
|
|
341
357
|
|
|
342
|
-
|
|
358
|
+
| Name | Arguments | Description |
|
|
359
|
+
| -------------- | ------------------- | --------------------------------------------------- |
|
|
360
|
+
| `get-help` | — | Return the server usage instructions. |
|
|
361
|
+
| `review-guide` | `tool`, `focusArea` | Guided workflow for a specific tool and focus area. |
|
|
343
362
|
|
|
344
|
-
|
|
345
|
-
| ------------------------ | --------- | ----------------------------------- |
|
|
346
|
-
| `stdio` | Yes | Active transport in `src/index.ts`. |
|
|
347
|
-
| HTTP/SSE/Streamable HTTP | No | Not implemented. |
|
|
363
|
+
## Configuration
|
|
348
364
|
|
|
349
365
|
### CLI Arguments
|
|
350
366
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
|
354
|
-
|
|
|
355
|
-
| `--model` | `-m` | Override the Gemini model id at startup. | `GEMINI_MODEL` |
|
|
356
|
-
| `--max-diff-chars` | — | Override the runtime diff-size budget. | `MAX_DIFF_CHARS` |
|
|
357
|
-
|
|
358
|
-
Example:
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
npx @j0hanz/code-review-analyst-mcp@latest --model gemini-2.5-pro --max-diff-chars 200000
|
|
362
|
-
```
|
|
367
|
+
| Option | Description | Env Var Equivalent |
|
|
368
|
+
| ------------------ | ---------------------- | ------------------ |
|
|
369
|
+
| `--model`, `-m` | Override default model | `GEMINI_MODEL` |
|
|
370
|
+
| `--max-diff-chars` | Override max diff size | `MAX_DIFF_CHARS` |
|
|
363
371
|
|
|
364
372
|
### Environment Variables
|
|
365
373
|
|
|
366
|
-
| Variable
|
|
367
|
-
|
|
|
368
|
-
| `GEMINI_API_KEY`
|
|
369
|
-
| `GOOGLE_API_KEY`
|
|
370
|
-
| `GEMINI_MODEL`
|
|
371
|
-
| `GEMINI_HARM_BLOCK_THRESHOLD`
|
|
372
|
-
| `MAX_DIFF_CHARS`
|
|
374
|
+
| Variable | Description | Default | Required |
|
|
375
|
+
| ------------------------------ | ---------------------------------------------------- | ------------ | -------- |
|
|
376
|
+
| `GEMINI_API_KEY` | Gemini API key | — | Yes |
|
|
377
|
+
| `GOOGLE_API_KEY` | Alternative API key (if `GEMINI_API_KEY` not set) | — | No |
|
|
378
|
+
| `GEMINI_MODEL` | Override default model selection | — | No |
|
|
379
|
+
| `GEMINI_HARM_BLOCK_THRESHOLD` | Safety threshold (BLOCK_NONE, BLOCK_ONLY_HIGH, etc.) | `BLOCK_NONE` | No |
|
|
380
|
+
| `MAX_DIFF_CHARS` | Max chars for diff input | `120000` | No |
|
|
381
|
+
| `MAX_CONTEXT_CHARS` | Max combined context for inspection | `500000` | No |
|
|
382
|
+
| `MAX_CONCURRENT_CALLS` | Max concurrent Gemini requests | `10` | No |
|
|
383
|
+
| `MAX_CONCURRENT_CALLS_WAIT_MS` | Max wait time for a free Gemini slot | `2000` | No |
|
|
384
|
+
| `MAX_CONCURRENT_CALLS_POLL_MS` | Poll interval while waiting for a free slot | `25` | No |
|
|
373
385
|
|
|
374
|
-
|
|
386
|
+
### Models
|
|
375
387
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
388
|
+
| Tool | Model | Thinking Budget |
|
|
389
|
+
| ------------------------- | ------------------ | --------------- |
|
|
390
|
+
| `analyze_pr_impact` | `gemini-2.5-flash` | — |
|
|
391
|
+
| `generate_review_summary` | `gemini-2.5-flash` | — |
|
|
392
|
+
| `inspect_code_quality` | `gemini-2.5-pro` | 16,384 tokens |
|
|
393
|
+
| `suggest_search_replace` | `gemini-2.5-pro` | 16,384 tokens |
|
|
394
|
+
| `generate_test_plan` | `gemini-2.5-flash` | 8,192 tokens |
|
|
381
395
|
|
|
382
|
-
##
|
|
396
|
+
## Workflows
|
|
383
397
|
|
|
384
|
-
|
|
398
|
+
### Quick PR Triage
|
|
385
399
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
npm start
|
|
390
|
-
```
|
|
400
|
+
1. Call `analyze_pr_impact` to get severity and category breakdown.
|
|
401
|
+
2. If low/medium — call `generate_review_summary` for a quick digest.
|
|
402
|
+
3. If high/critical — proceed to deep inspection.
|
|
391
403
|
|
|
392
|
-
|
|
404
|
+
### Deep Code Inspection
|
|
393
405
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
| `dev` | `tsc --watch --preserveWatchOutput` | TypeScript watch mode. |
|
|
398
|
-
| `dev:run` | `node --env-file=.env --watch dist/` | Run built server with watch and `.env`. |
|
|
399
|
-
| `test` | `node scripts/tasks.mjs test` | Full build + Node test runner. |
|
|
400
|
-
| `test:fast` | `node --test --import tsx/esm ...` | Fast test path on TS sources (no build step). |
|
|
401
|
-
| `type-check` | `node scripts/tasks.mjs type-check` | TypeScript no-emit checks. |
|
|
402
|
-
| `lint` | `eslint .` | ESLint checks. |
|
|
403
|
-
| `lint:fix` | `eslint . --fix` | ESLint auto-fix. |
|
|
404
|
-
| `format` | `prettier --write .` | Prettier formatting. |
|
|
405
|
-
| `inspector` | `npm run build && npx ... inspector` | MCP Inspector for the stdio server. |
|
|
406
|
+
1. Call `inspect_code_quality` with the diff and critical files in `files[]`.
|
|
407
|
+
2. Use `focusAreas` to target specific concerns (security, performance).
|
|
408
|
+
3. Review `findings` and `contextualInsights`.
|
|
406
409
|
|
|
407
|
-
|
|
408
|
-
> Set `TASK_TIMEOUT_MS` (env var) to enforce a timeout on build/test script tasks in `scripts/tasks.mjs`.
|
|
409
|
-
|
|
410
|
-
Debugging with MCP Inspector:
|
|
411
|
-
|
|
412
|
-
```bash
|
|
413
|
-
npx @modelcontextprotocol/inspector node dist/index.js
|
|
414
|
-
```
|
|
410
|
+
### Remediation & Testing
|
|
415
411
|
|
|
416
|
-
|
|
412
|
+
1. For each finding, call `suggest_search_replace` with `findingTitle` and `findingDetails`.
|
|
413
|
+
2. Call `generate_test_plan` to create a verification strategy.
|
|
414
|
+
3. Apply fixes and implement tests.
|
|
417
415
|
|
|
418
|
-
|
|
416
|
+
## Development
|
|
419
417
|
|
|
420
418
|
```bash
|
|
421
|
-
|
|
422
|
-
|
|
419
|
+
npm ci # Install dependencies
|
|
420
|
+
npm run dev # TypeScript watch mode
|
|
421
|
+
npm run dev:run # Run built server with .env and --watch
|
|
423
422
|
```
|
|
424
423
|
|
|
425
|
-
|
|
424
|
+
| Script | Command | Purpose |
|
|
425
|
+
| -------------------- | ----------------------------------- | ------------------------------ |
|
|
426
|
+
| `npm run build` | `node scripts/tasks.mjs build` | Clean, compile, validate, copy |
|
|
427
|
+
| `npm test` | `node scripts/tasks.mjs test` | Build + run all tests |
|
|
428
|
+
| `npm run test:fast` | `node --test --import tsx/esm ...` | Run tests without build |
|
|
429
|
+
| `npm run lint` | `eslint .` | Lint all files |
|
|
430
|
+
| `npm run lint:fix` | `eslint . --fix` | Lint and auto-fix |
|
|
431
|
+
| `npm run format` | `prettier --write .` | Format all files |
|
|
432
|
+
| `npm run type-check` | `node scripts/tasks.mjs type-check` | Type-check without emitting |
|
|
433
|
+
| `npm run inspector` | Build + launch MCP Inspector | Debug with MCP Inspector |
|
|
434
|
+
|
|
435
|
+
### Debugging with MCP Inspector
|
|
426
436
|
|
|
427
437
|
```bash
|
|
428
|
-
|
|
438
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
429
439
|
```
|
|
430
440
|
|
|
431
441
|
## Build & Release
|
|
432
442
|
|
|
433
|
-
Releases are
|
|
443
|
+
Releases are triggered via GitHub Actions `workflow_dispatch` with version bump selection (patch/minor/major/custom).
|
|
444
|
+
|
|
445
|
+
The pipeline runs lint, type-check, test, and build, then publishes to three targets in parallel:
|
|
434
446
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
4. **Docker image** — builds and pushes multi-arch (`linux/amd64`, `linux/arm64`) to `ghcr.io/j0hanz/code-review-analyst-mcp`.
|
|
447
|
+
- **npm** — `@j0hanz/code-review-analyst-mcp` with OIDC trusted publishing and provenance
|
|
448
|
+
- **Docker** — `ghcr.io/j0hanz/code-review-analyst-mcp` (linux/amd64, linux/arm64)
|
|
449
|
+
- **MCP Registry** — `io.github.j0hanz/code-review-analyst`
|
|
439
450
|
|
|
440
451
|
## Troubleshooting
|
|
441
452
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
453
|
+
| Issue | Solution |
|
|
454
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------ |
|
|
455
|
+
| `Missing GEMINI_API_KEY or GOOGLE_API_KEY` | Set one of the API key env vars in your MCP client config. |
|
|
456
|
+
| `E_INPUT_TOO_LARGE` | Diff or combined context exceeds budget. Split into smaller diffs or reduce files. |
|
|
457
|
+
| `Gemini request timed out` | Pro model tasks may take 60-120s. Increase your client timeout. |
|
|
458
|
+
| `Too many concurrent Gemini calls` | Reduce parallel tool calls or increase `MAX_CONCURRENT_CALLS`. |
|
|
459
|
+
| No tool output visible | Ensure your MCP client is not swallowing `stderr` — the server uses stdio transport. |
|
|
449
460
|
|
|
450
|
-
##
|
|
461
|
+
## License
|
|
451
462
|
|
|
452
|
-
|
|
453
|
-
- License: **MIT** (see `package.json`).
|
|
463
|
+
MIT
|