feat(mcp): add list and get tools for action log and tasks#40304
Draft
aminghadersohi wants to merge 5 commits into
Draft
feat(mcp): add list and get tools for action log and tasks#40304aminghadersohi wants to merge 5 commits into
aminghadersohi wants to merge 5 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #40304 +/- ##
==========================================
- Coverage 64.18% 64.18% -0.01%
==========================================
Files 2591 2599 +8
Lines 138455 138761 +306
Branches 32118 32133 +15
==========================================
+ Hits 88871 89064 +193
- Misses 48052 48163 +111
- Partials 1532 1534 +2
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:
|
The injected 7-day default filter used a datetime object as the value, but ActionLogFilter.value only allows str|int|float|bool|list. Pydantic rejects the datetime when building the filters_applied list in ActionLogList, causing a ValidationError on every call that triggered the default filter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add model_serializer to ActionLogInfo and TaskInfo that drops non-requested fields from output when select_columns context is set, matching the DatabaseInfo pattern - Switch list_action_logs and list_tasks to return model_dump with serialization context so only requested columns appear in responses - Add search field + search-XOR-filters validator to ListActionLogsRequest and ListTasksRequest - Pass search=request.search through to ModelListCore.run_tool() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rage - Add task_key and task_name fields to TaskInfo schema and ALL_TASK_COLUMNS; these are real Task model columns present in the REST API search_columns - Expand search_columns in list_tasks to include task_key and task_name - Strengthen test_list_action_logs_default_7day_filter_applied to also assert the injected filter appears in filters_applied with an ISO string value Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Pydantic v2 rejects a ColumnOperator instance when validating list[ActionLogFilter] — it requires an exact instance or dict, not a parent-class instance. The injected 7-day default dttm filter was created as a plain ColumnOperator, causing every test_list_action_logs_* call to fail with '1 validation error for ActionLogList'. Fix: construct the default filter as ActionLogFilter (which is a subclass of ColumnOperator), so it passes pydantic validation for ActionLogList.filters_applied: list[ActionLogFilter] and is still accepted everywhere ColumnOperator is expected.
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 4 new MCP tools across two new domains as part of story #99978:
Action Log domain (
superset/mcp_service/action_log/):list_action_logs: Lists audit log entries with filtering, pagination, and a default 7-day dttm window to prevent oversized result sets on large instances. Admin-only.get_action_log_info: Retrieves a single log entry by integer ID. Admin-only.Task domain (
superset/mcp_service/task/):list_tasks: Lists async tasks. Non-admin users are automatically scoped to tasks they are subscribed to viaTaskDAO.base_filter = TaskFilter. Admins see all tasks.get_task_info: Retrieves a single task by integer ID or UUID string.Both domains follow the established
ModelListCore/ModelGetInfoCorepatterns from the database domain.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — backend-only MCP tools.
TESTING INSTRUCTIONS
Run the new unit tests:
Key behaviors verified by tests:
list_action_logsinjects adttm >= now - 7 daysfilter when nodttmfilter is providedlist_action_logsskips the default filter when the caller provides adttmfilterlist_action_logsdefaults toorder_column=dttm, order_direction=desclist_tasksdelegates toTaskDAO.list()soTaskFilterscoping applies automaticallyget_task_inforesolves by both integer ID and UUID stringerror_type: not_foundresponsesADDITIONAL INFORMATION