Skip to content

feat(mcp): add list and get tools for action log and tasks#40304

Draft
aminghadersohi wants to merge 5 commits into
masterfrom
mcp-action-tasks-99978
Draft

feat(mcp): add list and get tools for action log and tasks#40304
aminghadersohi wants to merge 5 commits into
masterfrom
mcp-action-tasks-99978

Conversation

@aminghadersohi
Copy link
Copy Markdown
Contributor

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 via TaskDAO.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 / ModelGetInfoCore patterns from the database domain.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend-only MCP tools.

TESTING INSTRUCTIONS

Run the new unit tests:

pytest tests/unit_tests/mcp_service/action_log/
pytest tests/unit_tests/mcp_service/task/

Key behaviors verified by tests:

  • list_action_logs injects a dttm >= now - 7 days filter when no dttm filter is provided
  • list_action_logs skips the default filter when the caller provides a dttm filter
  • list_action_logs defaults to order_column=dttm, order_direction=desc
  • list_tasks delegates to TaskDAO.list() so TaskFilter scoping applies automatically
  • get_task_info resolves by both integer ID and UUID string
  • Not-found cases return structured error_type: not_found responses

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 63.07190% with 113 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.18%. Comparing base (68c145a) to head (7a89162).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...et/mcp_service/action_log/tool/list_action_logs.py 30.76% 27 Missing ⚠️
superset/mcp_service/action_log/schemas.py 75.53% 22 Missing and 1 partial ⚠️
superset/mcp_service/task/tool/list_tasks.py 33.33% 20 Missing ⚠️
superset/mcp_service/task/schemas.py 80.89% 16 Missing and 1 partial ⚠️
...mcp_service/action_log/tool/get_action_log_info.py 43.47% 13 Missing ⚠️
superset/mcp_service/task/tool/get_task_info.py 43.47% 13 Missing ⚠️
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     
Flag Coverage Δ
hive 39.52% <63.07%> (+0.11%) ⬆️
mysql 59.08% <63.07%> (+0.01%) ⬆️
postgres 59.16% <63.07%> (+0.01%) ⬆️
presto 41.20% <63.07%> (+0.10%) ⬆️
python 60.58% <63.07%> (+0.01%) ⬆️
sqlite 58.80% <63.07%> (+0.02%) ⬆️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

aminghadersohi and others added 4 commits May 20, 2026 23:14
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant