feat(mcp): add create_annotation_layer tool#40352
Draft
aminghadersohi wants to merge 1 commit into
Draft
Conversation
Adds a mutation tool that creates named annotation layers via CreateAnnotationLayerCommand, following the existing mutation pattern (create_virtual_dataset). Registers the tool in app.py under the annotation_layer module.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #40352 +/- ##
==========================================
- Coverage 64.20% 64.19% -0.01%
==========================================
Files 2592 2595 +3
Lines 139004 139054 +50
Branches 32273 32275 +2
==========================================
+ Hits 89241 89267 +26
- Misses 48231 48255 +24
Partials 1532 1532
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:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new MCP mutation tool to let MCP clients programmatically create Superset annotation layers by calling the existing CreateAnnotationLayerCommand, and wires the tool into MCP registration.
Changes:
- Introduces
create_annotation_layerMCP tool (mutation) that creates an annotation layer and returns{id, name, descr, error}. - Adds Pydantic request/response schemas for the new tool.
- Registers the new tool in the MCP app import registry.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| superset/mcp_service/app.py | Registers the new annotation-layer tool via import-time tool registration. |
| superset/mcp_service/annotation_layer/init.py | Adds new MCP service package namespace for annotation-layer tooling. |
| superset/mcp_service/annotation_layer/schemas.py | Defines Pydantic request/response schemas for create_annotation_layer. |
| superset/mcp_service/annotation_layer/tool/init.py | Exposes the tool function for import/registration. |
| superset/mcp_service/annotation_layer/tool/create_annotation_layer.py | Implements the MCP tool wrapper around CreateAnnotationLayerCommand with logging and error mapping. |
Comment on lines
+30
to
+33
| name: str = Field(..., description="Unique name for the annotation layer") | ||
| descr: str | None = Field( | ||
| None, description="Optional description of the annotation layer" | ||
| ) |
Comment on lines
+43
to
+46
| async def create_annotation_layer( | ||
| request: CreateAnnotationLayerRequest, ctx: Context | ||
| ) -> CreateAnnotationLayerResponse: | ||
| """Create a named annotation layer in Superset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Adds
create_annotation_layeras a new MCP mutation tool that allows AI assistants to create named annotation layers in Superset programmatically.The tool follows the existing mutation pattern (
create_virtual_dataset) and calls the existingCreateAnnotationLayerCommand. It accepts aname(required) and optionaldescr, validates uniqueness, and returns the created layer'sid,name, anddescr.New files:
superset/mcp_service/annotation_layer/__init__.pysuperset/mcp_service/annotation_layer/schemas.py—CreateAnnotationLayerRequest/CreateAnnotationLayerResponsePydantic schemassuperset/mcp_service/annotation_layer/tool/__init__.pysuperset/mcp_service/annotation_layer/tool/create_annotation_layer.py— the@toolimplementationModified:
superset/mcp_service/app.py— registers the new toolBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only change.
TESTING INSTRUCTIONS
create_annotation_layerwith{"request": {"name": "My Layer"}}ADDITIONAL INFORMATION