Skip to content

Comments

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

Open
bryankthompson wants to merge 1 commit intozerodha:masterfrom
bryankthompson:feat/add-tool-annotations
Open

feat: Add tool annotations for improved LLM tool understanding#62
bryankthompson wants to merge 1 commit intozerodha:masterfrom
bryankthompson:feat/add-tool-annotations

Conversation

@bryankthompson
Copy link

Summary

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

Changes

  • Added readOnlyHint: true to 16 read-only tools (get_, search_, login)
  • Added destructiveHint: true to 6 tools that modify data:
    • place_order, modify_order, cancel_order
    • place_gtt_order, delete_gtt_order, modify_gtt_order
  • Added title annotations for human-readable display

Files Modified:

File Tools Category
mcp/get_tools.go 9 Read-only
mcp/post_tools.go 6 Destructive
mcp/market_tools.go 5 Read-only
mcp/mf_tools.go 1 Read-only
mcp/setup_tools.go 1 Read-only

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 without user confirmation

Testing

  • Server builds successfully (go build ./...)
  • All tests pass (go test ./...)
  • Annotation values match actual tool behavior:
    • Order placement/modification/cancellation → destructive
    • Data queries and market data → read-only

Before/After

Before:

func (*PlaceOrderTool) Tool() mcp.Tool {
    return mcp.NewTool("place_order",
        mcp.WithDescription("Place an order"),
        mcp.WithString("variety", ...),
    )
}

After:

func (*PlaceOrderTool) Tool() mcp.Tool {
    return mcp.NewTool("place_order",
        mcp.WithDescription("Place an order"),
        mcp.WithTitleAnnotation("Place Order"),
        mcp.WithDestructiveHintAnnotation(true),
        mcp.WithString("variety", ...),
    )
}

🤖 Generated with Claude Code

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

Changes:
- Added readOnlyHint: true to 16 read-only tools (get_*, search_*, login)
- Added destructiveHint: true to 6 tools that modify data (place_order,
  modify_order, cancel_order, place_gtt_order, delete_gtt_order, modify_gtt_order)
- Added title annotations for human-readable display

Files modified:
- mcp/get_tools.go: 9 tools annotated
- mcp/post_tools.go: 6 tools annotated
- mcp/market_tools.go: 5 tools annotated
- mcp/mf_tools.go: 1 tool annotated
- mcp/setup_tools.go: 1 tool annotated

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