Skip to content

feat: Add tool annotations for improved LLM tool understanding#261

Merged
Goldziher merged 1 commit intokreuzberg-dev:mainfrom
bryankthompson:feat/add-tool-annotations
Jan 3, 2026
Merged

feat: Add tool annotations for improved LLM tool understanding#261
Goldziher merged 1 commit intokreuzberg-dev:mainfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson
Copy link
Contributor

Summary

Adds MCP tool annotations (readOnlyHint, destructiveHint, idempotentHint) to all 6 tools to help LLMs better understand tool behavior and make safer decisions about tool execution.

Changes

  • Added readOnlyHint: true to read-only tools (queries, extractions)
  • Added idempotentHint: true to deterministic operations
  • Added destructiveHint: true to cache_clear (permanently deletes files)
  • Added human-readable title annotations to all tools

Tool Annotation Summary

Tool Title ReadOnly Destructive Idempotent
extract_file Extract File -
extract_bytes Extract Bytes -
batch_extract_files Batch Extract Files -
detect_mime_type Detect MIME Type -
cache_stats Cache Stats -
cache_clear Clear Cache - -

Why This Matters

  • Annotations provide semantic metadata that helps LLMs understand tool behavior
  • LLMs can make better decisions about when to use tools and in what order
  • Enables safer tool execution by distinguishing read-only from destructive operations
  • MCP clients can auto-approve read-only operations and warn on destructive ones

Testing

  • Server builds successfully (cargo build --package kreuzberg)
  • Format check passes (cargo fmt --check)
  • MCP-related tests pass
  • Live verification: Started server and confirmed tools/list returns annotations
  • Annotation values match actual tool behavior

Before/After

Before:

{
  "name": "extract_file",
  "description": "Extract content from a file..."
}

After:

{
  "name": "extract_file",
  "description": "Extract content from a file...",
  "annotations": {
    "title": "Extract File",
    "readOnlyHint": true,
    "idempotentHint": true
  }
}

🤖 Generated with Claude Code

Add readOnlyHint, destructiveHint, and idempotentHint annotations to all
MCP tools to help LLMs better understand tool behavior and make safer
decisions about tool execution.

Changes:
- Added readOnlyHint: true to read-only tools (extract_file, extract_bytes,
  batch_extract_files, detect_mime_type, cache_stats)
- Added idempotentHint: true to deterministic read operations
- Added destructiveHint: true to cache_clear (permanently deletes files)
- Added human-readable title annotations to all tools

This improves tool safety metadata for MCP clients.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@Goldziher Goldziher merged commit 1abf858 into kreuzberg-dev:main Jan 3, 2026
43 of 55 checks passed
Goldziher added a commit that referenced this pull request Feb 13, 2026
feat: Add tool annotations for improved LLM tool understanding
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.

2 participants