feat: advertise MCP tool annotations on every tool #2

Manually merged
ric merged 0 commits from paulgit/forgejo-mcp:feat/tool-annotations into main 2026-11-22 21:35:16 +00:00
Contributor

Summary

All 457 Forgejo API tools and the lazy-mode load_tool_area tool now advertise
MCP ToolAnnotations (readOnlyHint, destructiveHint, idempotentHint,
openWorldHint) on tools/list. Clients can use these hints to gate permission
prompts, group read-only tools and auto-approve safe reads, instead of treating
every call as potentially destructive.

Changes

  • src/tools/helpers.ts: three explicit presets, READ_ONLY_TOOL (240 tools:
    all GET/getRaw tools plus the two read-only POST renderers),
    ADDITIVE_TOOL (67 purely additive creations), DESTRUCTIVE_TOOL (150
    non-additive edits, replacements, merges, removals and commands).
  • All nine src/tools/*.ts modules: each registration passes its preset via the
    SDK's five-argument server.tool overload. Handlers, schemas and HTTP calls
    are unchanged.
  • src/server.ts: load_tool_area annotated as a local session mutation
    (non-read-only, non-destructive, idempotent, closed-world).
  • Classification policies: destructiveHint is spec-strict (false only for
    purely additive operations); openWorldHint is true for every API tool;
    idempotentHint stays false for state-changing tools unless verified against
    Forgejo source. The one verified exception is get_runner_registration_token
    (GetOrCreateActiveRunnerToken converges on repeat).
  • Tests: compacted list preserves annotations; all 457 tools carry four boolean
    hints; representative tools pinned exactly; guard test ensures only the
    verified exception claims idempotency.
  • Docs: README, CLAUDE.md and CONTRIBUTING.md updated (classification rules for
    future tools).

Verification

  • npm test: 349/349 across 14 files; npm run lint, npx tsc --noEmit and
    npm run build clean.
  • End-to-end over an MCP client against the built server: 457 tools, zero
    missing annotations, 240 read-only / 67 additive / 150 destructive; lazy mode
    loads with loader-only and loaded tools carry identical annotations.

Notes

  • Additive only: no tool behaviour changes, no schema or handler changes.
  • Annotations are advisory hints from the server, not an authorisation or
    safety control.
  • block_user / org_block_user are destructive because upstream
    BlockUser also unfollows, unstars, unwatches, unassigns, removes
    collaborations and cancels pending transfers in one transaction.
## Summary All 457 Forgejo API tools and the lazy-mode `load_tool_area` tool now advertise MCP `ToolAnnotations` (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) on `tools/list`. Clients can use these hints to gate permission prompts, group read-only tools and auto-approve safe reads, instead of treating every call as potentially destructive. ## Changes - `src/tools/helpers.ts`: three explicit presets, `READ_ONLY_TOOL` (240 tools: all GET/getRaw tools plus the two read-only POST renderers), `ADDITIVE_TOOL` (67 purely additive creations), `DESTRUCTIVE_TOOL` (150 non-additive edits, replacements, merges, removals and commands). - All nine `src/tools/*.ts` modules: each registration passes its preset via the SDK's five-argument `server.tool` overload. Handlers, schemas and HTTP calls are unchanged. - `src/server.ts`: `load_tool_area` annotated as a local session mutation (non-read-only, non-destructive, idempotent, closed-world). - Classification policies: `destructiveHint` is spec-strict (false only for purely additive operations); `openWorldHint` is true for every API tool; `idempotentHint` stays false for state-changing tools unless verified against Forgejo source. The one verified exception is `get_runner_registration_token` (`GetOrCreateActiveRunnerToken` converges on repeat). - Tests: compacted list preserves annotations; all 457 tools carry four boolean hints; representative tools pinned exactly; guard test ensures only the verified exception claims idempotency. - Docs: README, CLAUDE.md and CONTRIBUTING.md updated (classification rules for future tools). ## Verification - `npm test`: 349/349 across 14 files; `npm run lint`, `npx tsc --noEmit` and `npm run build` clean. - End-to-end over an MCP client against the built server: 457 tools, zero missing annotations, 240 read-only / 67 additive / 150 destructive; lazy mode loads with loader-only and loaded tools carry identical annotations. ## Notes - Additive only: no tool behaviour changes, no schema or handler changes. - Annotations are advisory hints from the server, not an authorisation or safety control. - `block_user` / `org_block_user` are destructive because upstream `BlockUser` also unfollows, unstars, unwatches, unassigns, removes collaborations and cancels pending transfers in one transaction.
All 457 Forgejo API tools pass one of three explicit annotation
presets (read-only, additive, destructive) via the SDK five-argument
server.tool overload; load_tool_area is annotated as a local session
mutation. destructiveHint is spec-strict: false only for purely
additive operations. idempotentHint stays false for mutations except
get_runner_registration_token, verified against Forgejo source to
converge on repeat. Annotations pass through tool list compaction
unchanged; tests pin representative tools and guard the policy.
OCR review flagged block_user and org_block_user as additive, but
Gitea's BlockUser also unfollows both users, unstars, unwatches,
unassigns, removes collaborations and cancels pending transfers in
the same transaction, so neither operation is additive. Both move to
DESTRUCTIVE_TOOL; their inverses stay destructive because unblocking
removes the blocking record, like every other removal. block_user is
pinned in the representative annotation tests.
ric manually merged commit c9f0409178 into main 2026-11-22 21:35:16 +00:00
Owner

Thanks for this, changes are reviewed and merged and this will be released in v0.4.0

Thanks for this, changes are reviewed and merged and this will be released in v0.4.0
Sign in to join this conversation.
No reviewers
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
SquareCows/forgejo-mcp!2
No description provided.