gkneighb opened a new pull request, #41497:
URL: https://github.com/apache/superset/pull/41497

   ### SUMMARY
   
   The MCP server had no way to discover or create reusable **Themes**, even 
though dashboards can reference one via `theme_id` and `update_dashboard` can 
apply theme/CSS. So an agent (for example, one migrating a BI workbook) 
couldn't capture a brand palette/typography once and apply it consistently 
across dashboards. This PR adds a `theme` MCP module with three tools:
   
   - **`list_themes`** — discover themes with filtering/search/pagination 
(`ModelListCore`, mirroring the tag list tool).
   - **`get_theme_info`** — read a theme's antd design-token `json_data` by 
numeric ID **or UUID** (`ModelGetInfoCore`).
   - **`create_theme`** — create a reusable theme from an antd token 
configuration (accepts a JSON object **or** a JSON string). The config is 
sanitized and validated with the **same `_sanitize_and_validate_theme_config` 
routine the REST API uses** (token sanitization for XSS, font-URL validation, 
structure validation) before being persisted via `ThemeDAO`. User-created 
themes are stored with `is_system=False`, matching the REST API.
   
   The returned `theme_name` is wrapped via `sanitize_for_llm_context` 
(prompt-injection defense), consistent with the tag tools.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   python -m pytest tests/unit_tests/mcp_service/theme -q
   ```
   
   12 unit tests via the async MCP `Client`: list, get-by-ID, get-by-UUID, 
not-found, create-from-dict, create-from-JSON-string, invalid-config → 
`ValidationError`, invalid-JSON → `ValidationError`.
   
   Additionally verified end-to-end against a live instance (not committed): 
create → persist → `json_data` round-trip → `list` → `get` by ID and UUID; 
confirmed `brandSpinnerSvg` `<script>` content is scrubbed on persist, a 
structurally-invalid config returns `ValidationError` and writes **no** row, 
and `is_system=False`.
   
   `ruff` check + format and `mypy` are clean. Registered in `app.py` and 
listed in `DEFAULT_INSTRUCTIONS` (new "Theme Management" section).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to