@j0hanz/code-review-analyst-mcp 1.1.0 → 1.2.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.
Files changed (50) hide show
  1. package/README.md +203 -193
  2. package/dist/index.js +18 -15
  3. package/dist/instructions.md +83 -58
  4. package/dist/lib/context-budget.d.ts +8 -0
  5. package/dist/lib/context-budget.js +30 -0
  6. package/dist/lib/diff-budget.d.ts +3 -1
  7. package/dist/lib/diff-budget.js +16 -19
  8. package/dist/lib/diff-parser.d.ts +34 -0
  9. package/dist/lib/diff-parser.js +114 -0
  10. package/dist/lib/env-config.d.ts +5 -0
  11. package/dist/lib/env-config.js +24 -0
  12. package/dist/lib/errors.d.ts +1 -0
  13. package/dist/lib/errors.js +9 -6
  14. package/dist/lib/gemini-schema.d.ts +3 -1
  15. package/dist/lib/gemini-schema.js +18 -17
  16. package/dist/lib/gemini.d.ts +1 -0
  17. package/dist/lib/gemini.js +216 -111
  18. package/dist/lib/model-config.d.ts +17 -0
  19. package/dist/lib/model-config.js +19 -0
  20. package/dist/lib/tool-factory.d.ts +20 -8
  21. package/dist/lib/tool-factory.js +264 -67
  22. package/dist/lib/tool-response.d.ts +9 -2
  23. package/dist/lib/tool-response.js +29 -14
  24. package/dist/lib/types.d.ts +8 -3
  25. package/dist/prompts/index.js +35 -15
  26. package/dist/resources/index.js +10 -9
  27. package/dist/schemas/inputs.d.ts +27 -15
  28. package/dist/schemas/inputs.js +59 -21
  29. package/dist/schemas/outputs.d.ts +130 -7
  30. package/dist/schemas/outputs.js +170 -40
  31. package/dist/server.d.ts +5 -1
  32. package/dist/server.js +32 -24
  33. package/dist/tools/analyze-pr-impact.d.ts +2 -0
  34. package/dist/tools/analyze-pr-impact.js +46 -0
  35. package/dist/tools/generate-review-summary.d.ts +2 -0
  36. package/dist/tools/generate-review-summary.js +67 -0
  37. package/dist/tools/generate-test-plan.d.ts +2 -0
  38. package/dist/tools/generate-test-plan.js +56 -0
  39. package/dist/tools/index.js +10 -6
  40. package/dist/tools/inspect-code-quality.d.ts +4 -0
  41. package/dist/tools/inspect-code-quality.js +107 -0
  42. package/dist/tools/suggest-search-replace.d.ts +2 -0
  43. package/dist/tools/suggest-search-replace.js +46 -0
  44. package/package.json +3 -2
  45. package/dist/tools/review-diff.d.ts +0 -2
  46. package/dist/tools/review-diff.js +0 -42
  47. package/dist/tools/risk-score.d.ts +0 -2
  48. package/dist/tools/risk-score.js +0 -34
  49. package/dist/tools/suggest-patch.d.ts +0 -2
  50. package/dist/tools/suggest-patch.js +0 -35
package/README.md CHANGED
@@ -6,23 +6,22 @@
6
6
 
7
7
  [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](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) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](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) [![Install in Visual Studio](https://img.shields.io/badge/Visual_Studio-Install_Server-C16FDE?logo=visualstudio&logoColor=white)](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
- [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=Code+Review+Analyst&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovY29kZS1yZXZpZXctYW5hbHlzdC1tY3BAbGF0ZXN0Il19) [![Install in Goose](https://block.github.io/goose/img/extension-install-dark.svg)](https://block.github.io/goose/extension?cmd=npx&arg=-y%20%40j0hanz%2Fcode-review-analyst-mcp%40latest&id=code-review-analyst&name=Code%20Review%20Analyst&description=Gemini-powered%20MCP%20server%20for%20code%20review%20analysis.)
9
+ [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](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 runs over **stdio transport** and exposes three review-focused tools: `review_diff`, `risk_score`, and `suggest_patch`. It also publishes an `internal://instructions` resource and a `get-help` prompt for in-client guidance.
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
- - Structured review analysis with strict JSON output envelopes (`ok`, `result`, `error`).
20
- - Three complementary workflows: full review, release risk scoring, and targeted patch generation.
21
- - Runtime diff-size budget guard (`MAX_DIFF_CHARS`, default `120000`).
22
- - Optional task execution support (`execution.taskSupport: "optional"`) with in-memory task store.
23
- - Progress notifications when clients provide `_meta.progressToken`.
24
- - Shared Gemini adapter with timeout, retries, safety thresholds, and structured observability logs to `stderr`.
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>Install in VS Code</b></summary>
51
+ <summary><b>VS Code / VS Code Insiders</b></summary>
58
52
 
59
- [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](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
- [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](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
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](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) [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](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 install:
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>Install in Cursor</b></summary>
80
+ <summary><b>Cursor</b></summary>
90
81
 
91
- [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=Code+Review+Analyst&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovY29kZS1yZXZpZXctYW5hbHlzdC1tY3BAbGF0ZXN0Il19)
82
+ [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](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
- For more info, see [Cursor MCP docs](https://cursor.com/docs/context/mcp).
100
+ </details>
101
+
102
+ <details>
103
+ <summary><b>Visual Studio</b></summary>
104
+
105
+ [![Install in Visual Studio](https://img.shields.io/badge/Visual_Studio-Install_Server-C16FDE?logo=visualstudio&logoColor=white)](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>Install in Claude Desktop</b></summary>
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/docs/develop/connect-local-servers).
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>Install in Claude Code</b></summary>
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>Install in Windsurf</b></summary>
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/cascade/mcp).
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>Install in Amp</b></summary>
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://ampcode.com/manual).
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>Install in Cline</b></summary>
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/adding-and-configuring-servers).
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>Install in Zed</b></summary>
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": "npx",
214
- "args": ["-y", "@j0hanz/code-review-analyst-mcp@latest"]
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/ai/mcp).
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>Install with Docker</b></summary>
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
- > [!NOTE]
246
- > Set `GEMINI_API_KEY` in your shell environment before running. Docker passes it through via `-e GEMINI_API_KEY`.
272
+ Or build locally:
273
+
274
+ ```bash
275
+ docker build -t code-review-analyst-mcp .
276
+ ```
247
277
 
248
278
  </details>
249
279
 
250
- ## MCP Surface
280
+ ## Tools
251
281
 
252
- ### Tools
282
+ ### `analyze_pr_impact`
253
283
 
254
- #### `review_diff`
284
+ Assess the impact and risk of a pull request diff using the Flash model.
255
285
 
256
- Analyze a unified diff and return structured findings, overall merge risk, and test recommendations.
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
- | Name | Type | Required | Default | Description |
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
- Returns (inside `result`):
294
+ ### `generate_review_summary`
267
295
 
268
- - `summary`, `overallRisk` (`low|medium|high`), `findings[]`, `testsNeeded[]`
296
+ Summarize a pull request diff and assess high-level risk using the Flash model.
269
297
 
270
- Example:
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
- ```json
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
- Score deployment risk for a diff and explain the score drivers.
306
+ ### `inspect_code_quality`
296
307
 
297
- | Name | Type | Required | Default | Description |
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
- Returns (inside `result`):
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
- - `score` (`0..100`), `bucket` (`low|medium|high|critical`), `rationale[]`
319
+ **Returns:** `summary`, `overallRisk` (low/medium/high/critical), `findings[]` (severity, file, line, title, explanation, recommendation), `testsNeeded[]`, `contextualInsights[]`.
305
320
 
306
- #### `suggest_patch`
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
- Generate a focused unified-diff patch for one selected finding.
324
+ ### `suggest_search_replace`
309
325
 
310
- | Name | Type | Required | Default | Description |
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
- Returns (inside `result`):
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
- - `summary`, `patch` (unified diff text), `validationChecklist[]`
334
+ **Returns:** `summary`, `blocks[]` (file, search, replace, explanation), `validationChecklist[]`.
320
335
 
321
- ### Resources
336
+ ### `generate_test_plan`
322
337
 
323
- | URI | Name | MIME Type | Description |
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
- ### Prompts
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
- | Name | Description | Arguments |
330
- | ---------- | ---------------------------------- | --------- |
331
- | `get-help` | Returns server usage instructions. | None |
348
+ **Returns:** `summary`, `testCases[]` (name, type, file, description, pseudoCode, priority), `coverageSummary`.
332
349
 
333
- ### Tasks & Progress
350
+ ## Resources
334
351
 
335
- - Server declares `capabilities.tasks` with tool-call task support.
336
- - Each tool is registered with `execution.taskSupport: "optional"`.
337
- - Progress updates are emitted via `notifications/progress` when `_meta.progressToken` is provided.
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
- ## Configuration
356
+ ## Prompts
341
357
 
342
- ### Runtime Mode
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
- | Mode | Supported | Notes |
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
- The server binary accepts optional command-line flags:
352
-
353
- | Option | Short | Description | Env Override |
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 | Description | Default | Required |
367
- | ----------------------------- | --------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------- |
368
- | `GEMINI_API_KEY` | Gemini API key (preferred). | — | One of `GEMINI_API_KEY` or `GOOGLE_API_KEY` |
369
- | `GOOGLE_API_KEY` | Alternate Gemini API key env. | — | One of `GEMINI_API_KEY` or `GOOGLE_API_KEY` |
370
- | `GEMINI_MODEL` | Gemini model id. | `gemini-2.5-flash` | No |
371
- | `GEMINI_HARM_BLOCK_THRESHOLD` | Safety threshold (`BLOCK_NONE`, `BLOCK_ONLY_HIGH`, `BLOCK_MEDIUM_AND_ABOVE`, `BLOCK_LOW_AND_ABOVE`) | `BLOCK_NONE` | No |
372
- | `MAX_DIFF_CHARS` | Runtime diff-size budget (chars). | `120000` | No |
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
- ## Security
386
+ ### Models
375
387
 
376
- - Stdio transport avoids HTTP exposure in the current runtime path.
377
- - Runtime logs and warnings are written to `stderr`; no non-protocol output is written to `stdout`.
378
- - Input and output contracts use strict Zod schemas (`z.strictObject`) with explicit bounds.
379
- - Oversized diffs are rejected early with `E_INPUT_TOO_LARGE`.
380
- - Tool metadata marks calls as `readOnlyHint: true` and `openWorldHint: true` (external model call, no local state mutation).
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
- ## Development
396
+ ## Workflows
383
397
 
384
- Install and run locally:
398
+ ### Quick PR Triage
385
399
 
386
- ```bash
387
- npm install
388
- npm run build
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
- Useful scripts:
404
+ ### Deep Code Inspection
393
405
 
394
- | Script | Command | Purpose |
395
- | ------------ | ------------------------------------ | ----------------------------------------------------------------------- |
396
- | `build` | `node scripts/tasks.mjs build` | Clean, compile, validate instructions, copy assets, set executable bit. |
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
- > [!TIP]
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
- ### Docker
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
- Build and run locally with Docker:
416
+ ## Development
419
417
 
420
418
  ```bash
421
- docker build -t code-review-analyst-mcp .
422
- docker run -i --rm -e GEMINI_API_KEY code-review-analyst-mcp
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
- Or use Docker Compose:
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
- docker compose up --build
438
+ npx @modelcontextprotocol/inspector node dist/index.js
429
439
  ```
430
440
 
431
441
  ## Build & Release
432
442
 
433
- Releases are managed via the `Release` GitHub Actions workflow (manual dispatch):
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
- 1. **Version bump** — increments `package.json` and `server.json`, commits and tags.
436
- 2. **npm publish** — publishes `@j0hanz/code-review-analyst-mcp` with OIDC provenance.
437
- 3. **MCP Registry** — publishes `io.github.j0hanz/code-review-analyst` to the [MCP Registry](https://registry.modelcontextprotocol.io).
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
- - **`E_INPUT_TOO_LARGE`**: Split diff into smaller chunks or increase `MAX_DIFF_CHARS`.
443
- - **`E_REVIEW_DIFF` / `E_RISK_SCORE` / `E_SUGGEST_PATCH`**: Verify API key env vars and retry with narrower input.
444
- - **`Gemini request timed out after ...ms.`**: Reduce diff/prompt size or increase timeout in caller.
445
- - **`Gemini returned an empty response body.`**: Retry and check upstream model health.
446
- - **Malformed model JSON response**: Retry with same schema and inspect `stderr` logs.
447
- - **Inspector not connecting**: Ensure the server is built (`npm run build`) before running the inspector.
448
- - **Claude Desktop logs**: Check `~/Library/Logs/Claude/mcp*.log` (macOS) for server communication issues.
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
- ## Contributing & License
461
+ ## License
451
462
 
452
- - Contributions are welcome. Please open an issue or pull request on [GitHub](https://github.com/j0hanz/code-review-analyst-mcp).
453
- - License: **MIT** (see `package.json`).
463
+ MIT