Skip to content

fix(mcp): document all 7 generate_chart chart_type values#41598

Draft
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:amin/sc-106049/mcp-chart-tool-docs
Draft

fix(mcp): document all 7 generate_chart chart_type values#41598
aminghadersohi wants to merge 1 commit into
apache:masterfrom
aminghadersohi:amin/sc-106049/mcp-chart-tool-docs

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

The generate_chart MCP tool docstring only documented chart_type='xy' and chart_type='table', even though the underlying ChartConfig discriminated union has supported 7 chart types (xy, table, pie, pivot_table, mixed_timeseries, handlebars, big_number) since #38375/#38402/#38403. LLM clients calling the tool with intuitive-but-wrong values (e.g. chart_type='line', chart_type='bar', chart_type='pie' without realizing it needed dimension/metric) hit raw Pydantic discriminator errors and looped through retries/search_tools until timing out.

This PR:

  • Documents all 7 valid chart_type discriminator values directly in the tool docstring, with required fields for each.
  • Adds a natural-language "quick lookup" table mapping common asks ("bar chart", "pie chart", "pivot table", "KPI", etc.) to the correct chart_type (+ kind for XY charts), clarifying that line/bar/area/scatter are kind values within chart_type='xy', not chart_type values themselves.
  • Adds a worked example for chart_type='pie'.
  • Fixes a stale comment in MCP_TOOL_SEARCH_CONFIG that described include_schemas=False as the default; it has defaulted to True since fix(mcp): restore typed ChartConfig in tool schemas for LLM visibility #39732 (to keep discriminated-union configs visible to LLMs in search_tools results), but the comment still said otherwise.

No behavior change — docstring/comment only.

TESTING INSTRUCTIONS

  • python -m py_compile superset/mcp_service/chart/tool/generate_chart.py superset/mcp_service/mcp_config.py
  • Existing unit tests under tests/unit_tests/mcp_service/chart/tool/test_generate_chart.py continue to pass (no behavior touched).
  • Manually inspect the new tool docstring via get_chart_type_schema/search_tools output for generate_chart.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

…config comment

generate_chart's docstring only documented chart_type='xy'/'table', so
LLM clients calling with viz_type-style values like 'line', 'bar', or
'pie' as chart_type hit raw Pydantic discriminator errors and looped
through search_tools/retries until timing out. Document all 7 valid
chart_type values (xy, table, pie, pivot_table, mixed_timeseries,
handlebars, big_number) with required fields, a natural-language
quick-lookup table, and a pie chart example.

Also corrects a stale comment in MCP_TOOL_SEARCH_CONFIG that described
include_schemas=False as the default; it has defaulted to True since
apache#39732 to keep discriminated-union chart configs visible to LLMs.
@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 01cf28c
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a445822dd8bd500083da61b
😎 Deploy Preview https://deploy-preview-41598--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.09%. Comparing base (a5ece52) to head (01cf28c).
⚠️ Report is 318 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41598      +/-   ##
==========================================
- Coverage   64.35%   64.09%   -0.27%     
==========================================
  Files        2651     2659       +8     
  Lines      144804   146473    +1669     
  Branches    33413    33660     +247     
==========================================
+ Hits        93192    93879     +687     
- Misses      49944    50877     +933     
- Partials     1668     1717      +49     
Flag Coverage Δ
hive 39.10% <ø> (-0.23%) ⬇️
mysql 57.65% <ø> (-0.40%) ⬇️
postgres 57.72% <ø> (-0.41%) ⬇️
presto 40.65% <ø> (-0.26%) ⬇️
python 59.13% <ø> (-0.45%) ⬇️
sqlite 57.35% <ø> (-0.43%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants