Skip to content

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

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

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

Conversation

@bryankthompson

Copy link
Copy Markdown

Summary

Adds MCP tool annotations (readOnlyHint, title) to all 5 recipe query tools to help LLMs understand that these are safe, read-only operations.

Changes

All tools receive readOnlyHint: true annotation with English titles:

Tool Title Annotation
mcp_howtocook_getAllRecipes Get All Recipes readOnlyHint: true
mcp_howtocook_getRecipesByCategory Get Recipes by Category readOnlyHint: true
mcp_howtocook_getRecipeById Get Recipe by ID readOnlyHint: true
mcp_howtocook_recommendMeals Recommend Weekly Meals readOnlyHint: true
mcp_howtocook_whatToEat What to Eat readOnlyHint: true

Why This Matters

Tool annotations provide semantic metadata that:

  • Enables MCP clients to auto-approve safe read-only operations
  • Improves tool selection accuracy
  • Required for MCP Directory compliance

Testing

  • Build passes (npm run build)
  • tools/list returns all 5 tools with annotations
  • All annotations match actual tool behavior (all are read-only queries)

Before/After

Before:

server.tool(
  "mcp_howtocook_getAllRecipes",
  "获取所有菜谱",
  { /* schema */ },
  async () => { /* handler */ }
);

After:

server.tool(
  "mcp_howtocook_getAllRecipes",
  "获取所有菜谱",
  { /* schema */ },
  {
    title: "Get All Recipes",
    readOnlyHint: true,
  },
  async () => { /* handler */ }
);

Add readOnlyHint annotations to all 5 recipe query tools to help LLMs
understand that these are safe, read-only operations.

Changes:
- mcp_howtocook_getAllRecipes: title="Get All Recipes", readOnlyHint=true
- mcp_howtocook_getRecipesByCategory: title="Get Recipes by Category", readOnlyHint=true
- mcp_howtocook_getRecipeById: title="Get Recipe by ID", readOnlyHint=true
- mcp_howtocook_recommendMeals: title="Recommend Weekly Meals", readOnlyHint=true
- mcp_howtocook_whatToEat: title="What to Eat", readOnlyHint=true

This enables MCP clients to auto-approve these safe operations and
improves tool selection accuracy.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

1 participant