Skip to content

feat(mcp): declare title and tool annotations - #687

Merged
jimhoyd merged 1 commit into
mainfrom
feat/mcp-tool-title-annotations
Sep 24, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
feat/mcp-tool-title-annotations

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #677

What changed

  • packages/mcp/src/mcp.ts: optional top-level title (string, 1–256 chars) on the tool, resource and prompt config schemas and on McpToolSpec / McpResourceSpec / McpPromptSpec. Optional tool-only annotations, a closed object (additionalProperties: false) with the four boolean hints readOnlyHint, destructiveHint, idempotentHint, openWorldHint (new exported McpToolAnnotations type). No title inside annotations.
  • tools/list, resources/list and prompts/list echo these fields and leave out any that are absent. The shape matches the annotations object core's own MCP server (packages/core/src/mcp.ts) already emits.
  • The mcpAuthoring description now mentions title and annotations.
  • packages/mcp/urlcode.json was regenerated with npm run build:addons because it embeds the schema.
  • Docs: packages/mcp/README.md (YAML example, a field explanation stating the hints are advisory and never enforced, the list of what is implemented), packages/mcp/llms.txt (field list) and packages/mcp/CHANGELOG.md (Unreleased). docs/EXTENSIONS.md and docs/FRAMEWORK.md describe mcp without listing fields, so they needed no edit.

The diff stays inside the schemas, spec types, list responses and authoring text. handle() is untouched, which keeps this PR clear of the concurrent Origin/protocol-version work.

Evidence

  • npm run typecheck: exit 0
  • packages/mcp npm run verify: 22/22 tests pass, 2 of them new:
    • title and annotations are echoed in all three list responses, and absent fields are left out
    • config validation refuses an unknown hint, a non-boolean hint, title inside annotations, an empty title and a 257-char title. A control declaration carrying every valid hint and a title starts successfully, so each refusal comes from the one bad field.
  • Root npm run verify: exit 0, all suites pass (781, 22, 35, 95, 220, 14, 65, 3). The first run failed only because packages/mcp/urlcode.json was stale, and regenerating it fixed that.

Limitations

  • Core's validator reports a generic Invalid extension configuration: mcp without naming the field, so the refusal tests check that message and rely on the control case to show which field caused the refusal.
  • The hints are advisory metadata. The extension neither enforces nor checks them against what a handler actually does.
  • CI passing is not an independent security review.

🤖 Generated with Claude Code

Tools, resources and prompts accept an optional top-level `title`
(1-256 chars); tools accept optional `annotations` closed to the four
boolean MCP behavior hints. Both are echoed in tools/list,
resources/list and prompts/list and omitted when absent. Unknown hints,
non-boolean values and `title` inside annotations fail validation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the feat/mcp-tool-title-annotations branch from 5598e39 to 9d81482 Compare September 24, 2026 20:17
@jimhoyd
jimhoyd merged commit b9ff792 into main Sep 24, 2026
16 checks passed
@jimhoyd
jimhoyd deleted the feat/mcp-tool-title-annotations branch September 24, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: tool title and annotations in @jimhoyd/urlcode-mcp tool declarations

1 participant