Skip to content

feat(mcp): add list and get tools for CSS templates and themes#40302

Closed
aminghadersohi wants to merge 5 commits into
masterfrom
mcp-css-themes-99978
Closed

feat(mcp): add list and get tools for CSS templates and themes#40302
aminghadersohi wants to merge 5 commits into
masterfrom
mcp-css-themes-99978

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

SUMMARY

Implements 4 new MCP tools across two new domains as part of story #99978 (Add list and info MCP tools for all accessible menu features):

CSS Template domain (superset/mcp_service/css_template/):

  • list_css_templates: List CSS templates with filtering and search. CSS content excluded from default columns (large field) but requestable via select_columns=['css'].
  • get_css_template_info: Get full CSS template details by ID or UUID.

Theme domain (superset/mcp_service/theme/):

  • list_themes: List themes with filtering and search. Default columns include id, theme_name, uuid.
  • get_theme_info: Get theme details by ID or UUID (ThemeDAO supports UUID lookup).

Both domains follow the established database/dashboard/chart pattern: Pydantic schemas, ModelListCore/ModelGetInfoCore, schema_discovery.py column configs, app.py registration, and unit tests.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend MCP tools only.

TESTING INSTRUCTIONS

Run the new unit tests:

pytest tests/unit_tests/mcp_service/css_template/
pytest tests/unit_tests/mcp_service/theme/

Via MCP client:

list_css_templates({})
get_css_template_info({"request": {"identifier": 1}})
list_themes({})
get_theme_info({"request": {"identifier": "uuid-here"}})

ADDITIONAL INFORMATION

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 64.70588% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.09%. Comparing base (48cb3f5) to head (408e251).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...cp_service/css_template/tool/list_css_templates.py 34.37% 21 Missing ⚠️
superset/mcp_service/theme/tool/list_themes.py 34.37% 21 Missing ⚠️
superset/mcp_service/css_template/schemas.py 80.72% 15 Missing and 1 partial ⚠️
superset/mcp_service/theme/schemas.py 81.39% 15 Missing and 1 partial ⚠️
...service/css_template/tool/get_css_template_info.py 43.47% 13 Missing ⚠️
superset/mcp_service/theme/tool/get_theme_info.py 43.47% 13 Missing ⚠️
superset/mcp_service/common/schema_discovery.py 66.66% 4 Missing ⚠️
superset/mcp_service/system/tool/get_schema.py 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40302      +/-   ##
==========================================
- Coverage   64.15%   64.09%   -0.06%     
==========================================
  Files        2592     2600       +8     
  Lines      138861   139543     +682     
  Branches    32208    32304      +96     
==========================================
+ Hits        89085    89446     +361     
- Misses      48244    48552     +308     
- Partials     1532     1545      +13     
Flag Coverage Δ
hive 39.49% <64.70%> (+0.16%) ⬆️
mysql 58.80% <64.70%> (-0.06%) ⬇️
postgres 58.89% <64.70%> (-0.06%) ⬇️
presto 41.14% <64.70%> (+0.14%) ⬆️
python 60.43% <64.70%> (-0.07%) ⬇️
sqlite 58.53% <64.70%> (-0.05%) ⬇️
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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 force-pushed the mcp-css-themes-99978 branch 6 times, most recently from 894aa54 to d8aff1c Compare May 21, 2026 20:10
aminghadersohi and others added 4 commits May 21, 2026 21:14
Co-Authored-By: kasiazjc <kasiazjc@users.noreply.github.com>
… CSS templates and themes

- Remove dead _humanize_timestamp helper from css_template/schemas.py and
  theme/schemas.py (never called; database/schemas.py has the canonical copy)
- Add uuid field to CssTemplateInfo and serialize_css_template_object
  (CssTemplate inherits UUIDMixin)
- Add uuid to CSS_TEMPLATE_DEFAULT_COLUMNS alongside theme's existing uuid
- Register css_template and theme in get_schema tool so LLMs can discover
  column/filter/sort metadata for both new domains

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… and theme

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… for new model types

- Add is_system, is_system_default, is_system_dark to ThemeInfo and
  serialize_theme_object so schema discovery columns are fully serializable
- Add get_schema tests covering css_template and theme model types:
  default column assertions, search/sort columns, and request validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aminghadersohi aminghadersohi force-pushed the mcp-css-themes-99978 branch from d8aff1c to d441fe6 Compare May 21, 2026 21:14
pip install --upgrade uv downloads uv as a source distribution when no
pre-built wheel matches the platform (python:3.11-slim-trixie), then
fails to compile because cc is absent in the slim image. Using
COPY --from=ghcr.io/astral-sh/uv:latest ships a statically-linked
binary that works on any Linux regardless of glibc version, which is
the approach uv's own documentation recommends for Dockerfiles.
@aminghadersohi aminghadersohi marked this pull request as ready for review May 22, 2026 02:56
@dosubot dosubot Bot added the change:backend Requires changing the backend label May 22, 2026
@aminghadersohi aminghadersohi requested a review from geido May 22, 2026 02:58
@aminghadersohi
Copy link
Copy Markdown
Contributor Author

Closing in favor of a correctly named branch (amin/mcp-css-templates-themes). Re-opening as a new PR.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

Code Review Agent Run #795631

Actionable Suggestions - 1
  • superset/mcp_service/theme/tool/get_theme_info.py - 1
Additional Suggestions - 3
  • Dockerfile - 1
    • Floating :latest tag breaks reproducibility · Line 116-116
      Using `:latest` tag for uv breaks build reproducibility — each build may pull a different version. Pin to a specific version tag to ensure consistent, deterministic builds.
      Code suggestion
      --- Dockerfile (line 116) ---
       116: -COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
       116:+COPY --from=ghcr.io/astral-sh/uv:0.5.18 /uv /usr/local/bin/uv
  • superset/mcp_service/css_template/tool/get_css_template_info.py - 1
    • Error handling inconsistency · Line 99-108
      The outermost exception handler returns `CssTemplateError` instead of re-raising, bypassing the `GlobalErrorHandlerMiddleware` error classification and logging. Compare with `list_css_templates.py:144-150` which correctly re-raises. Per CLAUDE.md section 9, outermost exception handlers must re-raise so middleware handles it.
      Code suggestion
      --- superset/mcp_service/css_template/tool/get_css_template_info.py (lines 99-108) ---
       99:     except Exception as e:
       100:         await ctx.error(
       101:             "CSS template information retrieval failed: identifier=%s, error=%s, "
       102:             "error_type=%s" % (request.identifier, str(e), type(e).__name__)
       103:         )
       104:         return CssTemplateError(
       105:             error=f"Failed to get CSS template info: {str(e)}",
       106:             error_type="InternalError",
       107:             timestamp=datetime.now(timezone.utc),
       108:         )
      +    except Exception as e:
      +        await ctx.error(
      +            "CSS template information retrieval failed: identifier=%s, error=%s, "
      +            "error_type=%s" % (request.identifier, str(e), type(e).__name__)
      +        )
      +        raise
  • superset/mcp_service/theme/tool/list_themes.py - 1
    • Unused function parameter · Line 97-100
      The `_serialize_theme` function accepts a `cols` parameter but never uses it. This is inconsistent with similar serializers (e.g., `_serialize_chart` in list_charts.py:164-168) which only accept the object parameter. The field filtering is handled by `ThemeInfo._filter_fields_by_context` during serialization, not by the serializer function.
      Code suggestion
      --- superset/mcp_service/theme/tool/list_themes.py (lines 97-100) ---
       97:         def _serialize_theme(
       98: -            obj: "Theme | None", cols: list[str] | None
       99: +            obj: "Theme | None"
       100:         ) -> ThemeInfo | None:
Filtered by Review Rules

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

  • superset/mcp_service/constants.py - 1
Review Details
  • Files reviewed - 22 · Commit Range: e9de7b1..408e251
    • Dockerfile
    • superset/mcp_service/app.py
    • superset/mcp_service/common/schema_discovery.py
    • superset/mcp_service/constants.py
    • superset/mcp_service/css_template/__init__.py
    • superset/mcp_service/css_template/schemas.py
    • superset/mcp_service/css_template/tool/__init__.py
    • superset/mcp_service/css_template/tool/get_css_template_info.py
    • superset/mcp_service/css_template/tool/list_css_templates.py
    • superset/mcp_service/system/tool/get_schema.py
    • superset/mcp_service/theme/__init__.py
    • superset/mcp_service/theme/schemas.py
    • superset/mcp_service/theme/tool/__init__.py
    • superset/mcp_service/theme/tool/get_theme_info.py
    • superset/mcp_service/theme/tool/list_themes.py
    • tests/unit_tests/mcp_service/css_template/__init__.py
    • tests/unit_tests/mcp_service/css_template/tool/__init__.py
    • tests/unit_tests/mcp_service/css_template/tool/test_css_template_tools.py
    • tests/unit_tests/mcp_service/system/tool/test_get_schema.py
    • tests/unit_tests/mcp_service/theme/__init__.py
    • tests/unit_tests/mcp_service/theme/tool/__init__.py
    • tests/unit_tests/mcp_service/theme/tool/test_theme_tools.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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


return result

except Exception as e:
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.

Avoid catching blind Exception

Replace the broad Exception catch with specific exception types (e.g., ValueError, AttributeError, ThemeDAO.NotFound) to improve error handling and debugging.

Code Review Run #795631


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

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 size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant