Commit d699b62
authored
feat(mcp): add custom comment minimize tool (#45)
* feat(mcp): add custom comment minimize tool
* fix(mcp): harden custom review tool boundaries
* fix(mcp): enforce local write tool gate
* fix(mcp): normalize bot identity in minimize ownership check, make GraphQL testable
The ownership gate compared GraphQL viewer.login to the comment
author.login with strict equality. Empirically (verified against
api.github.com with a real installation token): viewer for an App
installation token is '<app-slug>[bot]' while Bot-authored comments
carry the bare '<app-slug>' author login — the check could never
pass for the App's own comments, i.e. the only comments the tool is
allowed to minimize. The feature was unusable and untested because
the GraphQL endpoint was a hard-coded const.
- normalize_actor() strips the '[bot]' suffix on both sides of the
comparison
- execute_graphql/handle_minimize_comment take the GraphQL URL as a
parameter (production callsite passes the api.github.com const)
- handler-level tests against a mock GraphQL server:
- App-bot-authored comment succeeds (viewer 'oab-ghpool[bot]' vs
author 'oab-ghpool' — the exact live API shape), mutation payload
asserted
- human-authored comment refused, zero mutations
- node in a different repository than the policy-checked owner/repo
refused (403), zero mutations
- GraphQL soft errors (HTTP 200 + errors[]) fail closed; unknown
classifier rejected before any network call
- drop the contradictory required+default classifier in the tool
schema (classifier is required)
Tests: ghpool 112 passed, clippy -D warnings clean.
---------
Co-authored-by: chaodu-agent <chaodu-agent@users.noreply.github.com>1 parent a61de55 commit d699b62
3 files changed
Lines changed: 638 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
364 | | - | |
| 364 | + | |
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
381 | 382 | | |
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
385 | 403 | | |
386 | 404 | | |
387 | 405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| 153 | + | |
0 commit comments