Skip to content

Conversation

@triepod-ai
Copy link

Summary

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

Changes

Read-only tools (readOnlyHint: true) - 8 tools:

  • read_file - Read file contents
  • list_directory - List directory contents
  • search_files - Search file names
  • get_file_info - Get file metadata
  • list_allowed_directories - List allowed directories
  • read_multiple_files - Read multiple files
  • tree - Directory structure
  • search_within_files - Search file contents

Destructive tools (destructiveHint: true) - 6 tools:

  • write_file - Create/overwrite files
  • create_directory - Create directories
  • copy_file - Copy files (creates new)
  • move_file - Move/rename files
  • delete_file - Delete files
  • modify_file - Modify file contents

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

  • Server builds successfully (go build ./...)
  • All tests pass (go test ./...)
  • Live verification: Started server and confirmed tools/list returns annotations
  • Annotation values match actual tool behavior (read-only vs destructive)

Before/After

Before:

s.AddTool(mcp.NewTool(
    "read_file",
    mcp.WithDescription("Read the complete contents of a file from the file system."),
    mcp.WithString("path", ...),
), h.HandleReadFile)

After:

s.AddTool(mcp.NewTool(
    "read_file",
    mcp.WithDescription("Read the complete contents of a file from the file system."),
    mcp.WithTitleAnnotation("Read File"),
    mcp.WithReadOnlyHintAnnotation(true),
    mcp.WithString("path", ...),
), h.HandleReadFile)

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

Changes:
- Added readOnlyHint: true to 8 read-only tools (read_file, list_directory,
  search_files, get_file_info, list_allowed_directories, read_multiple_files,
  tree, search_within_files)
- Added destructiveHint: true to 6 tools that modify data (write_file,
  create_directory, copy_file, move_file, delete_file, modify_file)
- Added title annotations for human-readable display

This improves tool safety metadata for MCP clients.

Co-Authored-By: Claude <noreply@anthropic.com>
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