list-workflow-runs
Retrieve and filter workflow runs from a GitHub repository by owner, repo, workflow ID, branch, or status using the GitHub Enterprise MCP Server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Filter by branch name | |
| owner | Yes | Repository owner | |
| page | No | Page number | |
| perPage | No | Items per page | |
| repo | Yes | Repository name | |
| status | No | Filter by run status | |
| workflow_id | No | Workflow ID or file name |
Implementation Reference
- server/index.ts:1250-1316 (handler)Main handler function for the 'list-workflow-runs' tool. Validates parameters, calls ActionsAPI.listWorkflowRuns, formats the response using formatWorkflowRun, and returns formatted MCP content.async ({ owner, repo, workflow_id, branch, status, page, perPage }) => { try { // Parameter validation if (!owner || typeof owner !== 'string' || owner.trim() === '') { return { content: [ { type: "text", text: "Repository owner is required." } ] }; } if (!repo || typeof repo !== 'string' || repo.trim() === '') { return { content: [ { type: "text", text: "Repository name is required." } ] }; } const response = await context.actions.listWorkflowRuns(owner, repo, { workflow_id, branch, status, page, per_page: perPage }); if (!response.workflow_runs || response.workflow_runs.length === 0) { return { content: [ { type: "text", text: workflow_id ? `No workflow runs found for workflow '${workflow_id}' in repository '${owner}/${repo}'.` : `No workflow runs found in repository '${owner}/${repo}'.` } ] }; } const formattedRuns = response.workflow_runs.map(formatWorkflowRun); return { content: [ { type: "text", text: `${workflow_id ? `Workflow '${workflow_id}'` : 'Workflow'} runs in repository '${owner}/${repo}' (${response.total_count}):\n\n${JSON.stringify(formattedRuns, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error listing workflow runs: ${error.message}` } ] }; } }
- server/index.ts:1242-1249 (schema)Zod input schema defining parameters for the list-workflow-runs tool.owner: z.string().min(1).describe("Repository owner"), repo: z.string().min(1).describe("Repository name"), workflow_id: z.union([z.string(), z.number()]).optional().describe("Workflow ID or file name"), branch: z.string().optional().describe("Filter by branch name"), status: z.enum(['completed', 'action_required', 'cancelled', 'failure', 'neutral', 'skipped', 'stale', 'success', 'timed_out', 'in_progress', 'queued', 'requested', 'waiting']).optional().describe("Filter by run status"), page: z.number().int().positive().optional().describe("Page number"), perPage: z.number().int().positive().optional().describe("Items per page") },
- server/index.ts:1240-1317 (registration)Registration of the 'list-workflow-runs' MCP tool using McpServer.tool() method."list-workflow-runs", { owner: z.string().min(1).describe("Repository owner"), repo: z.string().min(1).describe("Repository name"), workflow_id: z.union([z.string(), z.number()]).optional().describe("Workflow ID or file name"), branch: z.string().optional().describe("Filter by branch name"), status: z.enum(['completed', 'action_required', 'cancelled', 'failure', 'neutral', 'skipped', 'stale', 'success', 'timed_out', 'in_progress', 'queued', 'requested', 'waiting']).optional().describe("Filter by run status"), page: z.number().int().positive().optional().describe("Page number"), perPage: z.number().int().positive().optional().describe("Items per page") }, async ({ owner, repo, workflow_id, branch, status, page, perPage }) => { try { // Parameter validation if (!owner || typeof owner !== 'string' || owner.trim() === '') { return { content: [ { type: "text", text: "Repository owner is required." } ] }; } if (!repo || typeof repo !== 'string' || repo.trim() === '') { return { content: [ { type: "text", text: "Repository name is required." } ] }; } const response = await context.actions.listWorkflowRuns(owner, repo, { workflow_id, branch, status, page, per_page: perPage }); if (!response.workflow_runs || response.workflow_runs.length === 0) { return { content: [ { type: "text", text: workflow_id ? `No workflow runs found for workflow '${workflow_id}' in repository '${owner}/${repo}'.` : `No workflow runs found in repository '${owner}/${repo}'.` } ] }; } const formattedRuns = response.workflow_runs.map(formatWorkflowRun); return { content: [ { type: "text", text: `${workflow_id ? `Workflow '${workflow_id}'` : 'Workflow'} runs in repository '${owner}/${repo}' (${response.total_count}):\n\n${JSON.stringify(formattedRuns, null, 2)}` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error listing workflow runs: ${error.message}` } ] }; } } );
- api/actions/actions.ts:55-74 (helper)ActionsAPI.listWorkflowRuns method: core helper that makes the GitHub API call to list workflow runs.async listWorkflowRuns(owner: string, repo: string, options: { workflow_id?: number | string; actor?: string; branch?: string; event?: string; status?: 'completed' | 'action_required' | 'cancelled' | 'failure' | 'neutral' | 'skipped' | 'stale' | 'success' | 'timed_out' | 'in_progress' | 'queued' | 'requested' | 'waiting'; created?: string; page?: number; per_page?: number; } = {}): Promise<GitHubWorkflowRunListResponse> { const endpoint = options.workflow_id ? `repos/${owner}/${repo}/actions/workflows/${options.workflow_id}/runs` : `repos/${owner}/${repo}/actions/runs`; const { workflow_id, ...params } = options; return this.client.get<GitHubWorkflowRunListResponse>(endpoint, { params }); }
- server/index.ts:132-148 (helper)formatWorkflowRun helper function: formats individual workflow run data for user-friendly JSON output.function formatWorkflowRun(run: any) { return { id: run.id, name: run.name, workflow_id: run.workflow_id, run_number: run.run_number, event: run.event, status: run.status, conclusion: run.conclusion, created_at: run.created_at, updated_at: run.updated_at, url: run.html_url, head_branch: run.head_branch, head_sha: run.head_sha, run_attempt: run.run_attempt }; }