Skip to content

feat(mcp): filter asset lists by certification - #42656

Open
aminghadersohi wants to merge 3 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-certified-asset-filters
Open

feat(mcp): filter asset lists by certification#42656
aminghadersohi wants to merge 3 commits into
apache:masterfrom
aminghadersohi:aminghadersohi/mcp-certified-asset-filters

Conversation

@aminghadersohi

Copy link
Copy Markdown
Contributor

SUMMARY

Adds an optional tri-state certified field to the MCP list_datasets and list_charts request schemas:

  • true returns certified assets only
  • false returns uncertified assets only
  • omission preserves the existing unfiltered behavior

The tools reuse Superset's existing dataset and chart certification filters, keeping their semantics aligned with the REST APIs. The schema descriptions explicitly recommend the filter when an agent needs governed semantic-layer assets.

Why

MCP consumers otherwise need to retrieve every visible dataset or chart and filter the response client-side. Server-side filtering makes governed asset discovery explicit and can reduce response tokens without changing defaults.

What

A small adapter binds MCP request values to Flask-AppBuilder custom filters, and the shared list core passes those filters to the DAO. Both dataset and chart list tools expose the same tri-state request field.

Blast radius

Limited to authenticated MCP dataset and chart list calls. Existing RBAC/base filters remain in place and run before the certification filter. No database, migration, RLS, workspace-isolation, UI, or feature-flag changes.

Risk & rollback

Low risk. Omitted values retain the prior DAO query path. The main risk is divergence from certification semantics, mitigated by reusing the existing REST filter classes. Rollback is a normal revert.

Review guidance

Start with the request fields in the chart and dataset schemas, then review the bound-filter adapter and tool wiring. The most important behavior is that None does not install a custom filter.

Eval evidence

The affected MCP unit suites pass 99/99. The full staging agent eval suite was not run because this OSS worktree has no deployed staging build/workspace target.

Cost & latency delta

No model, prompt, routing, or model-parameter changes (0). Omitted-filter requests execute the same asset query as before. Opt-in certified filtering adds one existing SQL predicate and reduces returned rows; no deployed before/after token or latency sample is available from this worktree.

Prompt / non-determinism

No prompt or model-routing changes. The tool schema description is deterministic and is covered by request/tool tests.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable; no UI changes.

TESTING INSTRUCTIONS

pytest -q tests/unit_tests/mcp_service/chart/tool/test_list_charts.py \
  tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py

pre-commit run --files \
  superset/mcp_service/mcp_core.py \
  superset/mcp_service/dataset/schemas.py \
  superset/mcp_service/dataset/tool/list_datasets.py \
  superset/mcp_service/chart/schemas.py \
  superset/mcp_service/chart/tool/list_charts.py \
  tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py \
  tests/unit_tests/mcp_service/chart/tool/test_list_charts.py

The tests cover certified=true, certified=false, and omitted certification for both asset types.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.81818% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.73%. Comparing base (4278f4b) to head (2bd1efc).

Files with missing lines Patch % Lines
superset/mcp_service/mcp_core.py 41.66% 7 Missing ⚠️
superset/mcp_service/chart/tool/list_charts.py 0.00% 4 Missing ⚠️
superset/mcp_service/dataset/tool/list_datasets.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42656      +/-   ##
==========================================
- Coverage   65.73%   65.73%   -0.01%     
==========================================
  Files        2843     2843              
  Lines      162653   162670      +17     
  Branches    37239    37241       +2     
==========================================
+ Hits       106916   106924       +8     
- Misses      53644    53654      +10     
+ Partials     2093     2092       -1     
Flag Coverage Δ
hive 37.95% <31.81%> (-0.01%) ⬇️
mysql 57.78% <31.81%> (-0.01%) ⬇️
postgres 57.83% <31.81%> (-0.01%) ⬇️
presto 39.86% <31.81%> (-0.01%) ⬇️
python 59.20% <31.81%> (-0.01%) ⬇️
sqlite 57.46% <31.81%> (-0.01%) ⬇️
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.

@netlify

netlify Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 2bd1efc
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7430b3d2299500089426a5
😎 Deploy Preview https://deploy-preview-42656--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.

@aminghadersohi
aminghadersohi marked this pull request as ready for review August 4, 2026 23:43
@dosubot dosubot Bot added api Related to the REST API data:dataset Related to dataset configurations labels Aug 4, 2026
@github-actions github-actions Bot removed the api Related to the REST API label Aug 4, 2026
Comment thread superset/mcp_service/chart/schemas.py
Comment thread superset/mcp_service/chart/tool/list_charts.py Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The review suggestion is valid. Pydantic's default bool coercion can indeed silently convert truthy or falsy strings (like "false") or numbers (like 0) into boolean values, which may lead to unintended filtering behavior in the MCP tool. To enforce strict validation, you should use StrictBool from pydantic instead of bool for the certified field.

Would you like me to implement this change for the certified field in both superset/mcp_service/chart/schemas.py and superset/mcp_service/dataset/schemas.py? If you agree, I can also check the rest of the PR for similar issues.

superset/mcp_service/chart/schemas.py

from pydantic import Field, StrictBool

    certified: Annotated[
        StrictBool | None,
        Field(
            default=None,
            description=(
                "Filter by governance certification status. Use true to return "
                "only certified charts (preferred when selecting governed "
                "assets), false to return only uncertified charts, or omit to "
                "return both (default)."
            ),
        ),
    ]

@bito-code-review

bito-code-review Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #5f2c3f

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset/mcp_service/mcp_core.py - 1
    • Missing unit tests for build_bound_filter · Line 345-348
      The new `build_bound_filter` method lacks direct unit tests in `test_mcp_core.py` — only integration coverage exists via `test_list_charts_certified_filter` and `test_list_datasets_certified_filter`. Per BITO.md [11730], new tools/features should have dedicated unit tests covering success paths and error scenarios. Consider adding tests for: valid filter binding, invalid filter_class handling, and edge cases (None/empty value).
Filtered by Review Rules

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

  • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py - 2
Review Details
  • Files reviewed - 7 · Commit Range: 9f217ff..fd63bb4
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/dataset/schemas.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/mcp-certified-asset-filters branch from fd63bb4 to 440be3b Compare August 6, 2026 06:56
@aminghadersohi
aminghadersohi force-pushed the aminghadersohi/mcp-certified-asset-filters branch from 440be3b to 2bd1efc Compare August 6, 2026 06:58
@bito-code-review

bito-code-review Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3eeb90

Actionable Suggestions - 0
Additional Suggestions - 2
  • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.py - 1
    • Test assertion mismatch · Line 352-352
      The assertion checks for `lower(tables.extra) LIKE lower` but `DatasetCertifiedFilter` (line 50 in `filters.py`) uses `.ilike()` directly on `SqlaTable.extra`, which does NOT emit `lower()` in the SQL. The test may pass spuriously because it only triggers the `None` branch where this assertion is never evaluated.
  • superset/mcp_service/mcp_core.py - 1
    • Missing tests for build_bound_filter · Line 345-348
      The `build_bound_filter` method is a new public API but lacks dedicated unit tests. Per the project's test requirements, new tools and helper methods should include test coverage for success and failure scenarios.
Review Details
  • Files reviewed - 7 · Commit Range: 3d18672..2bd1efc
    • superset/mcp_service/chart/schemas.py
    • superset/mcp_service/chart/tool/list_charts.py
    • superset/mcp_service/dataset/schemas.py
    • superset/mcp_service/dataset/tool/list_datasets.py
    • superset/mcp_service/mcp_core.py
    • tests/unit_tests/mcp_service/chart/tool/test_list_charts.py
    • tests/unit_tests/mcp_service/dataset/tool/test_dataset_tools.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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@rebenitez1802 rebenitez1802 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.

LGTM

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

Labels

data:dataset Related to dataset configurations size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants