feat(DIARCHERS-1498): add MCP restart/abort/rerun endpoints#621
Open
sap-yuan wants to merge 1 commit into
Open
feat(DIARCHERS-1498): add MCP restart/abort/rerun endpoints#621sap-yuan wants to merge 1 commit into
sap-yuan wants to merge 1 commit into
Conversation
Backend:
- builds.py: POST .../builds/<bid>/restart, DELETE .../builds/<bid>/abort
- jobs.py: POST .../jobs/<jid>/restart, POST .../jobs/<jid>/rerun,
DELETE .../jobs/<jid>/abort
- All 5 ops require allow_trigger on the MCP token (403 otherwise)
- Rate-limited via trigger_build bucket (5 RPM)
- Full mcp_auth_required + check_project_access_mcp + audit_mcp coverage
- restart/rerun: delegate to same DB logic as existing /api/v1/* handlers
via shared _clone_jobs() helper; abort uses get_mcp_user_id() instead
of g.token['user']['id']
c7bbf87 to
6809a65
Compare
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
Implements DIARCHERS-1498 — exposes job restart, rerun, and abort capabilities via the MCP API namespace.
Depends on #620 (MCP traffic isolation — must merge first).
5 new endpoints
All require
allow_trigger = TRUEon the MCP token, project scope check, rate limiting (trigger_build bucket, 5 RPM), and audit logging.POST /api/v1/mcp/projects/<id>/builds/<bid>/restartDELETE /api/v1/mcp/projects/<id>/builds/<bid>/abortPOST /api/v1/mcp/projects/<id>/jobs/<jid>/restartPOST /api/v1/mcp/projects/<id>/jobs/<jid>/rerunDELETE /api/v1/mcp/projects/<id>/jobs/<jid>/abortKey design notes
restart_buildandrestart_jobdelegate to the same DB logic as the existing/api/v1/*handlers via a shared_clone_jobs()helper — no business logic duplicationabortendpoints useget_mcp_user_id()instead ofg.token['user']['id']since MCP auth sets a different contextrerun_job(single-job retry without downstream restart) is new — not currently in the regular/api/v1/*API as a separate verb, maps to the existing/rerunendpoint logicTest plan
restart_buildcreates a new build with incrementedrestart_counterabort_buildinserts abort records for all jobs in the buildrestart_jobclones job + all downstream dependents with.1suffixrerun_jobclones only the specified jobabort_jobinserts a single abort recordallow_trigger = FALSEon the tokenenabled_projectsmcp_access_logaudit entries