aminghadersohi opened a new pull request, #40340:
URL: https://github.com/apache/superset/pull/40340
## Summary
Adds a `create_dataset` MCP tool that lets callers register an existing
physical
database table as a Superset dataset — the programmatic equivalent of
**Data → Datasets → + Dataset** in the UI.
- **`CreateDatasetRequest` schema** — `database_id`, `schema` (alias for
`schema_name`
to avoid the Pydantic v2 `BaseModel.schema()` clash), `table_name`,
optional `catalog`
and `owners`; whitespace-only values for `schema`/`catalog` are normalised
to `None`
- **Pre-checks** — verifies the database exists and the caller has
table-level access
before calling the command
- **`create_dataset` tool** — wraps `CreateDatasetCommand`, uses
`DatasetInvalidError.get_list_classnames()` (public API) to classify
wrapped validation
errors; returns `DatasetInfo` (same shape as `get_dataset_info`) so the
`id` feeds
directly into `generate_chart` or `generate_explore_link`
- **Typed error handling** — distinct `error_type` values for each failure
class:
`DatabaseNotFoundError`, `AccessDeniedError`, `DatasetExistsError`,
`TableNotFoundError`, `ValidationError`, `CreateFailedError`,
`InternalError`
- **11 unit tests** — success, owners forwarding,
exists/not-found/validation/internal
errors, missing required fields, full `DatasetInfo` shape, database not
found,
access denied, no-schema, with-catalog
- **`DEFAULT_INSTRUCTIONS`** updated to list the new tool
## Motivation
The MCP service already exposes `create_virtual_dataset` for SQL-based
datasets. This
PR adds the physical-table counterpart so agents can complete the full
"find DB → register table → chart it" workflow without manual UI steps.
## Test plan
- [ ] `pytest
tests/unit_tests/mcp_service/dataset/tool/test_create_dataset.py -x`
- [ ] Existing dataset tool tests still pass
- [ ] `pre-commit run --files
superset/mcp_service/dataset/tool/create_dataset.py
superset/mcp_service/dataset/schemas.py`
--
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]