Skip to content

docs(mcp): document all 7 generate_chart chart_type values, fix stale config comment#41599

Draft
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:amin/sc-106049/mcp-generate-chart-docstring
Draft

docs(mcp): document all 7 generate_chart chart_type values, fix stale config comment#41599
aminghadersohi wants to merge 2 commits into
apache:masterfrom
aminghadersohi:amin/sc-106049/mcp-generate-chart-docstring

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

The generate_chart MCP tool's docstring only documented chart_type='xy' and chart_type='table', even though the underlying schema (ChartConfig discriminated union) has supported 5 additional chart types since #38375, #38402, and #38403: pie, pivot_table, mixed_timeseries, handlebars, and big_number.

Because the docstring is the primary signal an LLM client sees before calling the tool, models reaching for natural chart-type names like 'line', 'bar', or 'pie' directly as the chart_type value (instead of as a kind sub-field of chart_type='xy', or simply being unaware 'pie' was a valid discriminator at all) would hit the raw Pydantic discriminator validation error and loop through retries until timing out.

This PR only touches docstrings/comments — no schema, validation, or behavior changes:

  • generate_chart docstring now lists all 7 valid chart_type values with their required fields
  • Clarifies that kind (line/bar/area/scatter) is a sub-field of chart_type='xy', not a chart_type itself
  • Adds a natural-language → chart_type lookup table
  • Adds a pie chart example (previously only xy and table had examples)
  • 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 chart configs visible to LLMs without a second round trip)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — docstring/comment-only change, not user-facing UI.

TESTING INSTRUCTIONS

  1. ruff format --check / ruff check pass on both changed files
  2. Pre-commit hooks (mypy, ruff, pylint, docstring-first check) pass
  3. No tests assert on the literal docstring/comment text; existing tests/unit_tests/mcp_service/chart/tool/test_generate_chart.py suite is unaffected since only documentation (not schema or logic) changed

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

The generate_chart tool's docstring only described chart_type='xy'
and 'table', even though the schema has supported 'pie',
'pivot_table', 'mixed_timeseries', 'handlebars', and 'big_number'
since apache#38375/apache#38402/apache#38403. LLM clients calling chart_type='line' or
'bar' (a 'kind' value, not a chart_type) hit the raw Pydantic
discriminator error and looped through retries until timeout.

Lists all 7 valid chart_type values with their required fields, adds
a natural-language lookup table, and adds a pie chart example.
MCP_TOOL_SEARCH_CONFIG has defaulted include_schemas to True since
apache#39732 (to keep discriminated-union chart configs visible to LLMs
without a second round trip), but the comment above it still
described include_schemas=False as the default.
@aminghadersohi aminghadersohi changed the title docs(mcp): document all 7 generate_chart chart_type values docs(mcp): document all 7 generate_chart chart_type values, fix stale config comment Jul 1, 2026
@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.42%. Comparing base (35194fe) to head (4ce61b7).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41599      +/-   ##
==========================================
- Coverage   64.42%   64.42%   -0.01%     
==========================================
  Files        2668     2668              
  Lines      147182   147182              
  Branches    33947    33947              
==========================================
- Hits        94821    94816       -5     
- Misses      50646    50649       +3     
- Partials     1715     1717       +2     
Flag Coverage Δ
hive 39.10% <ø> (ø)
mysql 57.65% <ø> (ø)
postgres 57.72% <ø> (-0.01%) ⬇️
presto 40.65% <ø> (ø)
python 59.13% <ø> (-0.01%) ⬇️
sqlite 57.35% <ø> (ø)
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