Skip to content

feat(mcp): add feature-gated interactive pivot support - #43268

Closed
aminghadersohi wants to merge 6 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-interactive-pivot
Closed

aminghadersohi wants to merge 6 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-interactive-pivot

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Adds a distinct, feature-gated MCP adapter for Preset's ag-grid-pivot-table visualization. This deliberately does not alias Interactive Pivot to the OSS pivot_table_v2 adapter.

The new interactive_pivot schema and plugin cover:

  • AG Grid row groups, pivot columns, metrics, metric aggregation, totals/subtotals, formats, filters, sorting, and cell/series limits
  • persisted pivot_table_state for the Rows, Column Labels, and Values side-panel buckets
  • unsupported time-comparison fields are intentionally omitted until the Preset visualization consumes them, preventing false-success chart generation
  • schema discovery and examples, generated names, capabilities/semantics, and tabular chart-data handling
  • update/preview preservation of UI-managed AG Grid state while replacing declarative grouping and aggregation state
  • fail-closed availability through Preset's AG_GRID_PIVOT_TABLE_ENABLED feature flag plus the existing MCP plugin filter, so OSS-only deployments do not advertise an unavailable visualization

This implements the supported Interactive Pivot portion of SC-113786 and records the true AG Grid pivot as distinct from the OSS Pivot Table V2 delivered under SC-100129. Time comparison remains a visualization-side prerequisite: the current Preset plugin does not consume time_compare or comparison_type, so the MCP does not advertise those controls.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable. This changes MCP schemas and form-data generation; it does not add or modify UI components.

TESTING INSTRUCTIONS

  1. Enable AG_GRID_PIVOT_TABLE_ENABLED on a host that registers Preset's Interactive Pivot plugin.
  2. Call get_chart_type_schema("interactive_pivot") and verify the schema and examples are returned.
  3. Generate an Interactive Pivot with rows, columns, metrics, and totals; verify the Explore URL uses viz_type=ag-grid-pivot-table and its persisted grid state populates the AG Grid side-panel buckets.
  4. Update an existing Interactive Pivot and verify its concrete viz type remains ag-grid-pivot-table and UI-managed grid state such as sizing/filter/sort state is retained.
  5. Disable the feature flag and verify schema discovery and generation return DISABLED_CHART_TYPE rather than offering a broken chart.

Automated validation run:

PYTHONPATH="$PWD/superset-core/src:$PWD" pytest -q tests/unit_tests/mcp_service/chart
# 1307 passed

PYTHONPATH="$PWD/superset-core/src:$PWD" pytest -q \
  tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py \
  tests/unit_tests/mcp_service/chart/test_chart_utils.py \
  tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py \
  tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py
# 226 passed

pre-commit run
# Passed

pre-commit run --all-files
# Executed; changed-file hooks pass. The repository-wide baseline reports
# unrelated existing mypy/frontend type errors in untouched files.

ADDITIONAL INFORMATION

  • Has associated issue: SC-113786
  • Required feature flags: AG_GRID_PIVOT_TABLE_ENABLED
  • 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

AI behavior / evaluation evidence

This is a deterministic schema, validation, and form-data mapping change. Unit tests cover schema examples, exact native viz resolution, feature-gated availability, validation, omission of unsupported comparison fields, side-panel state, update/preview preservation, capabilities, and generated naming. No model prompt, routing, retrieval, or sampling behavior changes.

Cost and latency

No additional model calls or network requests are introduced. Availability checks are in-process feature-flag lookups; chart mapping remains deterministic and local.

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Aug 17, 2026
@netlify

netlify Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 895af43
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a8881a99d15db00086e0a3f
😎 Deploy Preview https://deploy-preview-43268--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 Aug 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 36.57143% with 111 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.75%. Comparing base (42ba2a4) to head (895af43).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...set/mcp_service/chart/plugins/interactive_pivot.py 29.54% 62 Missing ⚠️
superset/mcp_service/chart/schemas.py 68.00% 16 Missing ⚠️
superset/mcp_service/chart/chart_utils.py 9.09% 10 Missing ⚠️
superset/mcp_service/chart/registry.py 0.00% 10 Missing ⚠️
...et/mcp_service/chart/tool/get_chart_type_schema.py 0.00% 6 Missing ⚠️
...erset/mcp_service/chart/resources/chart_configs.py 0.00% 4 Missing ⚠️
superset/mcp_service/chart/plugin.py 50.00% 1 Missing ⚠️
superset/mcp_service/chart/tool/update_chart.py 0.00% 1 Missing ⚠️
...set/mcp_service/chart/tool/update_chart_preview.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43268      +/-   ##
==========================================
+ Coverage   66.73%   66.75%   +0.01%     
==========================================
  Files        2876     2877       +1     
  Lines      164278   164379     +101     
  Branches    37900    37937      +37     
==========================================
+ Hits       109633   109723      +90     
+ Misses      52483    52472      -11     
- Partials     2162     2184      +22     
Flag Coverage Δ
hive 38.09% <36.57%> (-0.03%) ⬇️
mysql 57.74% <36.57%> (-0.02%) ⬇️
postgres 57.78% <36.57%> (-0.02%) ⬇️
presto 40.02% <36.57%> (-0.03%) ⬇️
python 59.21% <36.57%> (+0.02%) ⬆️
sqlite 57.46% <36.57%> (+0.03%) ⬆️
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.

@aminghadersohi
aminghadersohi marked this pull request as ready for review August 20, 2026 20:10
@dosubot dosubot Bot added api Related to the REST API change:backend Requires changing the backend viz:charts:pivot Related to the Pivot Table charts labels Aug 20, 2026
@github-actions github-actions Bot removed the api Related to the REST API label Aug 20, 2026
Comment thread superset/mcp_service/app.py Resolved
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The display_name_for_viz_type() function currently iterates through all registered plugins to find a matching display name without verifying if the plugin is available in the current deployment. This allows the interactive_pivot display name to be returned even when the feature is disabled.

To resolve this, you should update display_name_for_viz_type (or the relevant lookup logic) to check plugin.is_available() before including the plugin's display name in the results.

Would you like me to fetch all other comments on this PR to validate them and implement a minimal fix for all of them?

superset/mcp_service/chart/plugin.py

def is_available(self) -> bool:
        """Return whether the host deployment provides this visualization."""
        return True

@bito-code-review

bito-code-review Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #bab818

Actionable Suggestions - 0
Additional Suggestions - 4
  • superset/mcp_service/chart/tool/update_chart.py - 1
    • Missing test for new feature · Line 241-241
      The new merge_interactive_pivot_ui_config integration lacks test coverage in test_update_chart.py. Add a test analogous to test_unrelated_config_update_preserves_existing_column_config (line 123) that verifies pivot_table_state is preserved when updating an ag-grid-pivot-table chart with an unrelated config. This addresses BITO.md rule [11730].
  • superset/mcp_service/chart/tool/update_chart_preview.py - 1
    • Missing test coverage for pivot merge · Line 42-42
      The `merge_interactive_pivot_ui_config` call at line 240 lacks test coverage in `test_update_chart_preview.py`. BITO.md [11730]/[11731] requires comprehensive unit tests for new MCP tool functionality, including validation of merge behavior when `previous_form_data` contains pivot table state.
  • superset/mcp_service/chart/chart_utils.py - 1
    • Missing unit tests for new merge function · Line 574-598
      Please add a `TestMergeInteractivePivotUiConfig` class in `tests/unit_tests/mcp_service/chart/test_chart_utils.py` with tests covering: (1) skipping non-pivot viz types, (2) preserving `column_config` and `conditional_formatting` when missing in new data, and (3) correctly merging `pivot_table_state` with existing and new entries.
  • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py - 1
    • Misleading fixture name · Line 31-34
      The fixture `enable_interactive_pivot` is named after one specific chart type but unconditionally enables *all* feature flags. Rename to `enable_all_feature_flags` and expand the docstring to clarify the intent: every registered adapter—including host-gated ones like `interactive_pivot`—must be exercised by the parametrized tests in `TestGetChartTypeSchema`.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py - 2
  • tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py - 1
  • superset/mcp_service/chart/plugin.py - 1
  • superset/mcp_service/chart/tool/get_chart_type_schema.py - 1
    • Test assertion mismatch after registry change · Line 240-240
Review Details
  • Files reviewed - 19 · Commit Range: 65e31ae..447cc36
    • docs/docs/using-superset/using-ai-with-superset.mdx
    • superset/mcp_service/app.py
    • superset/mcp_service/chart/chart_utils.py
    • superset/mcp_service/chart/plugin.py
    • superset/mcp_service/chart/plugins/__init__.py
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/registry.py
    • superset/mcp_service/chart/resources/chart_configs.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/generate_chart.py
    • superset/mcp_service/chart/tool/get_chart_data.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
    • superset/mcp_service/chart/tool/update_chart.py
    • superset/mcp_service/chart/tool/update_chart_preview.py
    • superset/mcp_service/chart/validation/schema_validator.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py
    • tests/unit_tests/mcp_service/chart/test_registry_filters.py
    • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py
    • tests/unit_tests/mcp_service/chart/tool/test_update_chart_preview.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Amin, thanks for this one. The gating mechanism is really well built. I checked out the branch and exercised it over MCP HTTP: with the flag off, schema discovery and generate_chart both fail closed with DISABLED_CHART_TYPE, and with the flag on I generated and saved a real chart whose pivot_table_state, control names, and aggregation mapping all line up with what the target plugin consumes. Full tests/unit_tests/mcp_service passes locally (3,527 tests). I also verified your replies on the display-name and time-grain threads against source and I agree with both.

One thing is blocking for me, on the comparison fields; details inline. Happy to dig in with you if there is viz-side context I am missing.

Two smaller notes, neither blocking:

  1. The pre-existing message in schema_validator.py ("registered but has been disabled by the operator", around line 189) is now reachable via the new is_available() gate, and on a vanilla OSS deployment it fires for a visualization the host simply does not ship, sending an admin hunting for a setting that does not exist. Your new message in get_chart_type_schema.py ("The host deployment does not provide...") gets this right; a similarly neutral phrasing there, e.g. "is not available on this instance", would cover both causes.

  2. Future-direction note: the gap this PR closes for the pivot still exists for ag-grid-table. MainPreset.ts registers that viz only when AG_GRID_TABLE_ENABLED is on (default False in config.py), but the MCP table plugin advertises viz_type="ag-grid-table" unconditionally, so MCP can offer and generate a chart the host will not render. is_available() is per chart_type so it does not directly fit a native viz_type gate, but it feels like the natural follow-up to this work. Worth a follow-up issue?

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Addressed the remaining review concerns in 895af43772:

  • Changed the disabled-chart validation detail to the neutral “not available on this instance” wording, covering both operator filtering and host-unavailable visualizations.
  • Removed unsupported Interactive Pivot time-comparison controls and claims throughout schema discovery, mapping, examples, docs, and tests.
  • Added focused unit coverage for Interactive Pivot UI-config preservation/merge behavior in test_chart_utils.py; saved-update and cached-preview integration coverage remains in the feature/tool tests.
  • Renamed the all-feature-flags schema fixture to reflect its actual scope.

I agree the pre-existing ag-grid-table native-viz gating gap is worth a separate follow-up. It needs variant-level availability within the table chart type rather than this PR’s chart-type-level hook, so I have kept that scope separate to avoid changing the stable table adapter here.

Validation: full MCP chart suite 1,307 passed, focused review suite 226 passed, and changed-file pre-commit hooks passed.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Tracked the AG Grid Table native-viz availability follow-up as SC-118029, scoped to variant-level discovery, validation, generation/update gating, and tests while preserving the regular OSS table adapter.

@aminghadersohi

Copy link
Copy Markdown
Contributor Author

Tracked the visualization-side time-comparison prerequisite and subsequent MCP restoration as SC-118030, so removing the unsupported fields here does not lose the original product requirement.

@bito-code-review bito-code-review Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #da35c7

Actionable Suggestions - 1
  • docs/docs/using-superset/using-ai-with-superset.mdx - 1
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/mcp_service/chart/schemas.py - 1
Review Details
  • Files reviewed - 9 · Commit Range: 447cc36..895af43
    • docs/docs/using-superset/using-ai-with-superset.mdx
    • superset/mcp_service/chart/plugins/interactive_pivot.py
    • superset/mcp_service/chart/resources/chart_configs.py
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/get_chart_type_schema.py
    • superset/mcp_service/chart/validation/schema_validator.py
    • tests/unit_tests/mcp_service/chart/test_chart_utils.py
    • tests/unit_tests/mcp_service/chart/test_interactive_pivot_chart.py
    • tests/unit_tests/mcp_service/chart/tool/test_get_chart_type_schema.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@gabotorresruiz gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick and thorough turnaround, Amin. I checked out 895af43 and re-verified everything empirically:

  • map_interactive_pivot_config emits no comparison keys, and the published schema and examples contain none. A config that still carries time_compare or comparison_type now fails loudly with the same unknown-field hint every other chart type gives, which is the right shape for LLM self-correction, and nothing released ever wrote those keys into saved params.
  • The disabled-chart detail now reads "not available on this instance" on the flag-off path; I confirmed the new wording end to end through SchemaValidator.
  • tests/unit_tests/mcp_service/chart passes locally at this head (1,307 tests) and CI is green. The one smoke-test failure I saw locally reproduces identically at the previous head in my environment, so it is environmental, not this change.

Also appreciate the follow-up issues for the ag-grid-table availability gap and the visualization-side comparison prerequisite, plus the fixture rename. LGTM.

@aminghadersohi aminghadersohi closed this by deleting the head repository Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend doc Namespace | Anything related to documentation review:draft size/XXL viz:charts:pivot Related to the Pivot Table charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants