aminghadersohi opened a new pull request, #40345:
URL: https://github.com/apache/superset/pull/40345
### SUMMARY
Adds four new MCP (Model Context Protocol) tools giving AI assistants
admin-level access to user and role directory information in Superset:
- **`list_users`** — paginated listing with filtering/search/column
selection. Sensitive fields (`email`) require explicit `select_columns` opt-in;
`roles` is only available via `get_user_info` (relationship, not a DAO column).
- **`get_user_info`** — fetch a single user by ID. Returns `email` and
`roles` when caller has data model metadata access.
- **`list_roles`** — paginated listing of roles with filtering/search/column
selection.
- **`get_role_info`** — fetch a single role by ID.
Privacy is enforced at the field level: sensitive fields are null when the
caller lacks `data_model_metadata` access, rather than hiding the tool entirely
(allowing admins to always discover the tool).
Follows the existing `database/`, `dashboard/`, `dataset/`, `chart/` MCP
domain patterns:
- `ModelListCore` / `ModelGetInfoCore` reusable base classes
- `@model_serializer(mode="wrap")` on `UserInfo` / `RoleInfo` for
`select_columns` context filtering (same pattern as `DatabaseInfo`,
`DashboardInfo`)
- `model_dump(context={"select_columns": ...})` in list tools
- `RoleDAO(BaseDAO[Role])` placed in `superset/daos/role.py` (consistent
with all other DAOs)
- `event_logger.log_context()` instrumentation
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend MCP tools only, no UI changes.
### TESTING INSTRUCTIONS
1. Unit tests:
```bash
pytest tests/unit_tests/mcp_service/user/tool/test_user_tools.py -v
pytest tests/unit_tests/mcp_service/role/tool/test_role_tools.py -v
```
2. Manual via MCP client (requires Superset running with MCP enabled and
admin credentials):
```
list_users {}
list_users {"request": {"search": "admin"}}
list_users {"request": {"select_columns": ["id", "email"]}}
get_user_info {"request": {"identifier": 1}}
list_roles {}
get_role_info {"request": {"identifier": 1}}
```
### 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]