Skip to content

Comments

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

Open
bryankthompson wants to merge 1 commit intoMarkusPfundstein:mainfrom
bryankthompson:feat/add-tool-annotations
Open

feat: Add tool annotations for improved LLM tool understanding#101
bryankthompson wants to merge 1 commit intoMarkusPfundstein:mainfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson
Copy link

Summary

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

Changes

  • Bump MCP SDK from >=1.1.0 to >=1.8.0 for annotation support
  • Added readOnlyHint: true to 9 read-only tools (queries, fetches)
  • Added destructiveHint: true to 4 tools that create/update/delete data
  • Added title annotations for human-readable display

Tool Classification

Read-Only Tools (9):

Tool Title
obsidian_list_files_in_vault List Files in Vault
obsidian_list_files_in_dir List Files in Directory
obsidian_get_file_contents Get File Contents
obsidian_simple_search Simple Search
obsidian_complex_search Complex Search
obsidian_batch_get_file_contents Batch Get File Contents
obsidian_get_periodic_note Get Periodic Note
obsidian_get_recent_periodic_notes Get Recent Periodic Notes
obsidian_get_recent_changes Get Recent Changes

Destructive Tools (4):

Tool Title
obsidian_append_content Append Content
obsidian_patch_content Patch Content
obsidian_put_content Put Content
obsidian_delete_file Delete File

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 (like Claude Code) can auto-approve read-only tools while prompting for destructive ones

Testing

  • MCP SDK updated to 1.25.0 (supports annotations)
  • uv sync completes successfully
  • Pyright type check passes (0 errors)
  • Tool annotations verified via Python test script
  • All 13 tools have correct readOnlyHint or destructiveHint values

Before/After

Before:

Tool(
    name="obsidian_delete_file",
    description="Delete a file or directory from the vault.",
    inputSchema={...}
)

After:

Tool(
    name="obsidian_delete_file",
    description="Delete a file or directory from the vault.",
    inputSchema={...},
    annotations=ToolAnnotations(
        title="Delete File",
        destructiveHint=True,
    ),
)

🤖 Generated with Claude Code

Add readOnlyHint and destructiveHint annotations to all 13 tools
to help LLMs better understand tool behavior and make safer decisions.

Changes:
- Bump MCP SDK from >=1.1.0 to >=1.8.0 for annotation support
- Added readOnlyHint: true to 9 read-only tools:
  - obsidian_list_files_in_vault
  - obsidian_list_files_in_dir
  - obsidian_get_file_contents
  - obsidian_simple_search
  - obsidian_complex_search
  - obsidian_batch_get_file_contents
  - obsidian_get_periodic_note
  - obsidian_get_recent_periodic_notes
  - obsidian_get_recent_changes
- Added destructiveHint: true to 4 write/destructive tools:
  - obsidian_append_content
  - obsidian_patch_content
  - obsidian_put_content
  - obsidian_delete_file
- 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)

Co-Authored-By: Claude <noreply@anthropic.com>
ernestkoe added a commit to ernestkoe/mcp-obsidian-ek that referenced this pull request Dec 29, 2025
Added ToolAnnotations with readOnlyHint/destructiveHint to key tools:
- ListFilesInVault, ListFilesInDir, GetFileContents (readOnly)
- AppendContent, DeleteFile (destructive)

Establishes the pattern; remaining tools can be annotated incrementally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
larsboes added a commit to larsboes/mcp-obsidian that referenced this pull request Jan 8, 2026
- Implement Tool Annotations (readOnlyHint, destructiveHint) for safer LLM usage (matches PR MarkusPfundstein#101)
- Fix: list_files_in_dir returns empty list on 404 (handling empty dirs)
- Feat: Enhance Smart Context tool to include backlinks
- Upgrade mcp dependency to >=1.8.0
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