Skip to content

Conversation

@triepod-ai
Copy link

Summary

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

Changes

  • Added readOnlyHint: true to listTables (read-only table listing)
  • Added readOnlyHint: true to describeTable (read-only schema lookup)
  • Added destructiveHint: true to executeQuery (can execute INSERT/UPDATE/DELETE queries)
  • Added title annotations for human-readable display

Why This Matters

Tool annotations provide semantic metadata that MCP clients can use to:

  • Auto-approve safe operations: Clients like Claude Code can automatically approve read-only tools without user confirmation
  • Prompt for confirmation: Destructive tools trigger confirmation prompts before execution
  • Display meaningful titles: Human-readable names improve UI/UX in client applications
  • Enable safer automation: Workflows can distinguish between read and write operations

Tool Summary

Tool Title ReadOnly Destructive
listTables List Tables -
describeTable Describe Table -
executeQuery Execute Query -

Testing

  • Code follows mcp-go annotation patterns (WithTitleAnnotation, WithReadOnlyHintAnnotation, WithDestructiveHintAnnotation)
  • Using mcp-go v0.41.0 which fully supports annotations
  • Annotation values match actual tool behavior

Note: Live verification requires full Anyquery setup with database plugins. The annotation syntax follows the established mcp-go library patterns.

Before/After

Before:

tool := mcp.NewTool("listTables", 
    mcp.WithDescription("Lists all the tables..."))

After:

tool := mcp.NewTool("listTables",
    mcp.WithDescription("Lists all the tables..."),
    mcp.WithTitleAnnotation("List Tables"),
    mcp.WithReadOnlyHintAnnotation(true),
)

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

Changes:
- Added readOnlyHint: true to listTables (read-only query)
- Added readOnlyHint: true to describeTable (read-only schema lookup)
- Added destructiveHint: true to executeQuery (can execute INSERT/UPDATE/DELETE)
- Added title annotations for human-readable display

This improves tool safety metadata for MCP clients like Claude Code,
which can auto-approve read-only tools and prompt for confirmation
on destructive operations.

Co-Authored-By: Claude <[email protected]>
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