aminghadersohi opened a new pull request, #38532:
URL: https://github.com/apache/superset/pull/38532

   ### SUMMARY
   
   Fixes three issues with MCP tool calls reported when using external MCP 
clients (Grok, etc.):
   
   1. **`open_sql_lab_with_context` returned relative URLs** (`/sqllab?...`) 
while every other tool returns absolute URLs via `get_superset_base_url()`. 
This forced LLMs to guess the base URL, leading to hallucinated `{{ 
preset_base_url }}` template syntax or broken links.
   
   2. **LLMs fabricate URLs** instead of calling chart tools — the 
`DEFAULT_INSTRUCTIONS` lacked explicit guardrails telling LLMs to never invent 
URLs and always use tool results.
   
   3. **LLMs call `execute_sql` instead of `update_chart`** when asked to 
modify chart filters — the instructions didn't include a "modify an existing 
chart" workflow or parameter name reminders.
   
   **Changes:**
   - `open_sql_lab_with_context.py`: Import `get_superset_base_url` and use it 
to construct absolute SQL Lab URLs, matching the pattern used by 
`generate_chart`, `generate_dashboard`, `add_chart_to_existing_dashboard`, etc.
   - `app.py` (`DEFAULT_INSTRUCTIONS`): Add anti-hallucination guardrails 
(never fabricate URLs, use `update_chart` for chart modifications, correct 
parameter names) and a "modify an existing chart" workflow section.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A — backend-only change to MCP tool output and instructions text.
   
   ### TESTING INSTRUCTIONS
   1. Connect an MCP client (e.g., Claude Desktop, Grok) to the Superset MCP 
service
   2. Ask the chatbot to "open SQL Lab for database X" — verify the returned 
URL is absolute (starts with `http://...`) not relative (`/sqllab?...`)
   3. Ask "add a filter to chart 123" — verify it uses `update_chart`, not 
`execute_sql`
   4. Ask "show me a chart of sales data" — verify it calls 
`generate_explore_link` or `generate_chart` instead of fabricating a URL
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to