From ba6cfdc8bde03c8fd5eb89005057f9f2940dc8c6 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Mon, 19 Jan 2026 01:53:37 +0000 Subject: [PATCH] feat: Update demo agent prompt to always pass schema parameter Update the demo_agent_claude.sh prompt to instruct the LLM to always pass the schema parameter when calling run_sql_readonly. Changes: - System prompt now uses unquoted heredoc (ENDPROMPT) to expand $SCHEMA variable - Updated tool description to show schema parameter as required - Updated workflow steps to show schema="$SCHEMA" in llm_search and run_sql_readonly calls - Added explicit instruction: "ALWAYS provide schema="$SCHEMA" to run_sql_readonly" - Updated example interaction to show schema parameter being passed - Changed "Ready to help" line from hardcoded "Chinook" to dynamic $SCHEMA This ensures queries run against the correct database schema, fixing the issue where queries would execute against the default schema instead of the discovered schema. --- scripts/mcp/demo_agent_claude.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/mcp/demo_agent_claude.sh b/scripts/mcp/demo_agent_claude.sh index d1a6c0640..c0a3e3128 100755 --- a/scripts/mcp/demo_agent_claude.sh +++ b/scripts/mcp/demo_agent_claude.sh @@ -86,8 +86,8 @@ EOF # Create system prompt using heredoc to preserve special characters SYSTEM_PROMPT_FILE=$(mktemp) -cat > "$SYSTEM_PROMPT_FILE" << 'ENDPROMPT' -You are an intelligent SQL Query Agent for the Chinook database schema. You have access to a Model Context Protocol (MCP) server that provides tools for database discovery and query generation. +cat > "$SYSTEM_PROMPT_FILE" << ENDPROMPT +You are an intelligent SQL Query Agent for the $SCHEMA database schema. You have access to a Model Context Protocol (MCP) server that provides tools for database discovery and query generation. ## Available MCP Tools @@ -99,7 +99,7 @@ You have access to these MCP tools (use mcp__proxysql-stdio__ prefix): - ALWAYS use include_objects=true to get object schemas in one call - avoids extra catalog_get_object calls! 2. **run_sql_readonly** - Execute a read-only SQL query - - Parameters: sql (the query to execute) + - Parameters: sql (the query to execute), schema (ALWAYS provide schema: "$SCHEMA") - Returns: Query results ## Your Workflow - Show Step by Step @@ -107,7 +107,7 @@ You have access to these MCP tools (use mcp__proxysql-stdio__ prefix): When a user asks a natural language question, follow these steps explicitly: Step 1: Search for Similar Queries (with object schemas included!) -- Call llm_search with: run_id, query (keywords), include_objects=true +- Call llm_search with: run_id="$SCHEMA", query (keywords), include_objects=true - This returns BOTH matching question templates AND complete object schemas - Show the results: question templates found + their related objects' schemas @@ -117,7 +117,8 @@ Step 2: Analyze Results - If no good match, use the object schemas from search results to generate new query Step 3: Execute Query -- Call run_sql_readonly with the SQL (either from example_sql or newly generated) +- Call run_sql_readonly with: sql (from example_sql or newly generated), schema="$SCHEMA" +- ALWAYS provide the schema parameter! - Show the results Step 4: Present Results @@ -126,10 +127,11 @@ Step 4: Present Results ## Important Notes - ALWAYS use include_objects=true with llm_search - this is critical for efficiency! +- ALWAYS provide schema="$SCHEMA" to run_sql_readonly - this ensures queries run against the correct database! - Always show your work - Explain each step you're taking - Use llm_search first with include_objects=true - get everything in one call - Score interpretation: Lower scores = better match (< -3.0 is good) -- run_id: Always use the schema name (e.g., 'Chinook') as the run_id +- run_id: Always use "$SCHEMA" as the run_id - The llm_search response includes: - question templates with example_sql - related_objects (array of object names) @@ -176,13 +178,13 @@ Related objects: Track schema (columns: TrackId, Name, UnitPrice, etc.) Step 2: Reusing the example_sql from the match... Step 3: Execute the query... -[run_sql_readonly call] +[run_sql_readonly call with schema="$SCHEMA"] Step 4: Results: [table of tracks] --- -Ready to help! Ask me anything about the Chinook database. +Ready to help! Ask me anything about the $SCHEMA database. ENDPROMPT # Create append prompt (initial task)