Add anti-guessing hint to execute_sql_query MCP tool description#5
Open
jtiisto wants to merge 1 commit into
Open
Add anti-guessing hint to execute_sql_query MCP tool description#5jtiisto wants to merge 1 commit into
jtiisto wants to merge 1 commit into
Conversation
The execute_sql_query docstring is surfaced verbatim as the MCP tool description, but it lists only a few example columns and never tells the model to confirm the schema first. With daily_health_metrics carrying 50+ columns, memoryless LLM clients extrapolate column names and hit "no such column" errors. The sibling tools (get_table_details, explore_database_structure) already point forward ("use me first"); this adds the missing backward pointer from execute_sql_query to get_table_details plus an explicit "do NOT guess". Docstring-only -- no logic or behavior change; re-exports on server reload.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds a three-line anti-guessing hint to the
execute_sql_querytool description in the localdb MCP server, pointing clients toget_table_detailsbefore they write queries.Why
The
execute_sql_querydocstring is surfaced verbatim as the MCP tool description that LLM clients read. Today it pitches the tool and lists a handful of example columns, but it never tells the model to confirm the schema first. The sibling tools already signpost the workflow forward —explore_database_structureandget_table_detailsboth say "use me first" — yet the tool a model actually jumps to,execute_sql_query, has no backward pointer and no "don't guess" instruction.With
daily_health_metricscarrying 50+ columns (only a few of which appear in the examples), a memoryless client extrapolates the rest and fails:Query execution failed: no such column…The change
Insert immediately after the
IMPORTANT: Only SELECT…line:This closes the
explore_database_structure → get_table_details → queryloop at the point of use — the one place the chain wasn't signposted.Scope & safety
DailyHealthMetricmodel (57 mapped columns).ruff format --checkpasses and the change introduces no new lint findings.