cancel_workflow_run
Stop a GitHub Actions workflow run by specifying the repository owner, repository name, and workflow run ID using this tool. Simplify workflow management with direct cancellation functionality.
Instructions
Cancel a workflow run
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| runId | Yes | The ID of the workflow run |
Implementation Reference
- src/operations/actions.ts:248-261 (handler)The handler function that performs the actual cancellation of a GitHub Actions workflow run by sending a POST request to the GitHub API endpoint.export async function cancelWorkflowRun( owner: string, repo: string, runId: number ) { owner = validateOwnerName(owner); repo = validateRepositoryName(repo); const url = `https://api.github.com/repos/${owner}/${repo}/actions/runs/${runId}/cancel`; await githubRequest(url, { method: 'POST' }); // This endpoint doesn't return any data on success return { success: true, message: `Workflow run ${runId} cancelled` }; }
- src/operations/actions.ts:77-81 (schema)Zod schema defining the input parameters for the cancel_workflow_run tool: owner, repo, and runId.export const CancelWorkflowRunSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), runId: z.number().describe("The ID of the workflow run"), });
- src/index.ts:216-223 (registration)Registration of the cancel_workflow_run tool in the MCP server using server.tool(), linking to the schema and handler.server.tool( "cancel_workflow_run", actions.CancelWorkflowRunSchema.shape, async (request: any) => { const result = await actions.cancelWorkflowRun(request.owner, request.repo, request.runId); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );