trigger-workflow
Initiate GitHub workflow executions by specifying repository details, workflow ID, Git reference, and inputs. Integrates with GitHub Enterprise API for streamlined process automation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | No | Workflow inputs | |
| owner | Yes | Repository owner | |
| ref | Yes | Git reference (branch, tag, SHA) | |
| repo | Yes | Repository name | |
| workflow_id | Yes | Workflow ID or file name |
Implementation Reference
- server/index.ts:1320-1397 (registration)Registration of the MCP tool 'trigger-workflow', including Zod input schema (owner, repo, workflow_id, ref, inputs) and handler function that performs parameter validation and calls ActionsAPI.dispatchWorkflowserver.tool( "trigger-workflow", { owner: z.string().min(1).describe("Repository owner"), repo: z.string().min(1).describe("Repository name"), workflow_id: z.union([z.string(), z.number()]).describe("Workflow ID or file name"), ref: z.string().min(1).describe("Git reference (branch, tag, SHA)"), inputs: z.record(z.string()).optional().describe("Workflow inputs") }, async ({ owner, repo, workflow_id, ref, inputs }) => { 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." } ] }; } if (!workflow_id) { return { content: [ { type: "text", text: "Workflow ID or filename is required." } ] }; } if (!ref || typeof ref !== 'string' || ref.trim() === '') { return { content: [ { type: "text", text: "Git reference (branch, tag, or SHA) is required." } ] }; } await context.actions.dispatchWorkflow(owner, repo, workflow_id, { ref, inputs }); return { content: [ { type: "text", text: `Successfully triggered workflow '${workflow_id}' in repository '${owner}/${repo}' on ref '${ref}'.` } ] }; } catch (error: any) { return { content: [ { type: "text", text: `Error triggering workflow: ${error.message}` } ] }; } } );
- api/actions/actions.ts:124-126 (handler)Core handler function that executes the GitHub API POST request to trigger a workflow_dispatch eventasync dispatchWorkflow(owner: string, repo: string, workflowId: number | string, options: WorkflowDispatchOptions): Promise<void> { await this.client.post(`repos/${owner}/${repo}/actions/workflows/${workflowId}/dispatches`, options); }
- api/actions/types.ts:104-107 (schema)TypeScript interface defining the options structure for dispatching a workflow (ref and optional inputs)export interface WorkflowDispatchOptions { ref: string; // The git reference for the workflow (branch, tag, HEAD) inputs?: Record<string, string>; // Input parameters defined in the workflow file }
- server/index.ts:1322-1328 (schema)Zod validation schema for the 'trigger-workflow' tool inputs{ owner: z.string().min(1).describe("Repository owner"), repo: z.string().min(1).describe("Repository name"), workflow_id: z.union([z.string(), z.number()]).describe("Workflow ID or file name"), ref: z.string().min(1).describe("Git reference (branch, tag, SHA)"), inputs: z.record(z.string()).optional().describe("Workflow inputs") },
- server/index.ts:163-173 (helper)Creation and inclusion of ActionsAPI instance in the MCP server context, enabling access to workflow actions from tool handlersconst actions = new ActionsAPI(client); const pulls = PullsAPI; const issues = IssuesAPI; // Create context const context: GitHubContext = { client, repository, admin, actions, pulls,