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

   ## TL;DR
   
   - MCP clients can add, update, and remove dashboard markdown tiles, section 
headers, and dividers without constructing a replacement layout.
   - Typed operations preserve charts and dashboard metadata, reject invalid 
batches before saving, and return component IDs for subsequent edits.
   - Existing dashboard rendering is unchanged; this adds a structured 
authoring interface.
   
   ## Why
   
   `update_dashboard` accepts a complete `position_json` replacement, making a 
text-only edit require knowledge of the entire layout tree. A dedicated 
`manage_dashboard_markdown` tool follows `manage_native_filters`' batched 
operation pattern without mixing full-layout replacement and incremental edits 
in one request.
   
   ### SUMMARY
   
   Discriminated schemas cover markdown, header, and divider additions; updates 
merge compatible metadata fields; removals prune empty rows/columns while 
retaining tabs. Markdown gets a new row, while headers/dividers attach directly 
to the grid or selected tab, matching the frontend component contract. The tool 
requires Dashboard write permission and object-level editorship, validates the 
layout before/after changes, and protects the reserved dashboard-title node.
   
   Placement and pruning helpers are shared with chart add/remove tools. 
Registration, mutation-cache exclusions, committed-write response handling, and 
user documentation are included.
   
   **Size rationale:** this is one tool contract across schema, layout 
operations, registration, docs, and regression tests; the shared-helper 
extraction moves existing chart-tool logic rather than duplicating it.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: clients must hand-build raw layout JSON for text edits. After: 
clients submit typed component operations. No frontend rendering changes. 
Screenshots and live UI verification were not performed; only unit-test 
infrastructure was used.
   
   ### TESTING INSTRUCTIONS
   
   Automated checks: **837 passed** across the selected surface, including 
**42**
   markdown-tool tests. Changed-branch pre-commit checks passed, including mypy,
   ruff formatting/lint, and pylint.
   
   ```bash
   pytest -q tests/unit_tests/mcp_service/dashboard \
     tests/unit_tests/mcp_service/test_mcp_tool_registration.py \
     tests/unit_tests/mcp_service/test_auth_rbac.py \
     tests/unit_tests/mcp_service/utils/test_response_size_utils.py
   pre-commit run --files <changed files>
   ```
   
   The markdown-tool tests exercise all component types, partial updates, 
field/type validation, malformed layouts, batch atomicity, chart/metadata 
preservation, tab parent chains, authorization errors, and commit/refresh 
failures.
   
   Manual verification for an MCP-enabled instance:
   
   1. As a dashboard editor, call `manage_dashboard_markdown` with:
      ```json
      
{"request":{"dashboard_id":42,"add":[{"component_type":"header","text":"Overview"},{"component_type":"markdown","code":"**Updated
 daily**","width":12},{"component_type":"divider"}]}}
      ```
   2. Load the dashboard and verify the appended components and existing 
charts. On a tabbed dashboard, also add a tile with `target_tab` set to a tab 
name or ID.
   3. Update a returned markdown ID with `{"id":"MARKDOWN-…","code":"Revised 
notes"}`, then remove that ID. Verify neighboring charts and tabs remain intact.
   4. Submit an incompatible field or unknown component ID and verify the 
dashboard stays unchanged. Repeat as a non-editor and verify denial.
   
   ## Risk & rollback
   
   Shared placement helpers also serve chart addition/removal; their regression 
tests are included. Layout writes retain last-write-wins behavior under 
concurrent editing. Moving/reordering components and changing component types 
are intentionally outside this tool. Reverting the change removes the MCP 
interface; saved components remain ordinary dashboard layout nodes. No 
migrations or new feature flags.
   
   ## Eval evidence
   
   Deterministic MCP client/unit tests were run. Model-driven evals and 
repeated tool-selection trials were not run and remain follow-up validation 
before promotion from draft.
   
   ## Cost & latency delta
   
   Not measured. No model or routing changes; the MCP tool inventory gains one 
schema. No token, cost, or latency improvement is claimed.
   
   ## Prompt / non-determinism
   
   The only server-instruction changes are the tool's dashboard-management 
entry and write-permission listing. No sampling-parameter or model-routing 
changes; tool-selection variance is unmeasured.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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