feat: Add tool annotations for improved LLM tool understanding #122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds MCP tool annotations (
readOnlyHint,destructiveHint,title) to all tools to help LLMs better understand tool behavior and make safer decisions about tool execution.Changes
Bump MCP SDK dependency from
>=1.5.0to>=1.8.0(required for annotation support in FastMCP)Add
ToolAnnotationsimport frommcp.typesAdd
readOnlyHint: trueto 8 read-only tools:list_schemaslist_objectsget_object_detailsexplain_queryanalyze_workload_indexesanalyze_query_indexesanalyze_db_healthget_top_queriesAdd
execute_sqltool with mode-aware annotations:UNRESTRICTEDmode:destructiveHint: true(can modify data)RESTRICTEDmode:readOnlyHint: true(read-only queries)Add
titleannotations for human-readable tool namesWhy This Matters
readOnlyHinttells the LLM a tool is safe to call without side effectsdestructiveHintsignals the LLM should be more careful before executingtitleprovides human-readable names for better UXTesting
uv syncfrom postgres_mcp.server import mcp)mcp._tool_manager._toolsBefore/After
Before:
After:
Compatibility
This PR bumps the minimum MCP SDK version from 1.5.0 to 1.8.0. The
ToolAnnotationsparameter in@mcp.tool()decorator was added in later SDK versions.🤖 Generated with Claude Code