feat(mcp): add list and get tools for CSS templates and themes#40302
feat(mcp): add list and get tools for CSS templates and themes#40302aminghadersohi wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
894aa54 to
d8aff1c
Compare
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>
d8aff1c to
d441fe6
Compare
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.
|
Closing in favor of a correctly named branch (amin/mcp-css-templates-themes). Re-opening as a new PR. |
There was a problem hiding this comment.
Code Review Agent Run #795631
Actionable Suggestions - 1
-
superset/mcp_service/theme/tool/get_theme_info.py - 1
- Avoid catching blind Exception · Line 107-107
Additional Suggestions - 3
-
Dockerfile - 1
-
Floating :latest tag breaks reproducibility · Line 116-116Using `: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-108The 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-100The `_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
- Incomplete type definition · Line 22-24
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
|
|
||
| return result | ||
|
|
||
| except Exception as e: |
There was a problem hiding this comment.
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
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 viaselect_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 includeid,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.pycolumn configs,app.pyregistration, and unit tests.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend MCP tools only.
TESTING INSTRUCTIONS
Run the new unit tests:
Via MCP client:
ADDITIONAL INFORMATION