create_commit_status
Track and update GitHub commit statuses (success, failure, pending, error) for repositories. Provide a state, target URL, description, and context to manage CI/CD workflows and build notifications.
Instructions
Create a status for a commit (build passed/failed, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | A string label to differentiate this status from others | |
| description | No | A short description of the status | |
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| sha | Yes | The SHA of the commit to create a status for | |
| state | Yes | The state of the status | |
| target_url | No | The target URL to associate with this status |
Implementation Reference
- src/operations/statuses.ts:55-79 (handler)The main handler function that executes the tool logic by making a POST request to the GitHub API to create a commit status.export async function createCommitStatus( github_pat: string, owner: string, repo: string, sha: string, state: "error" | "failure" | "pending" | "success", options: { target_url?: string; description?: string; context?: string; } = {} ): Promise<z.infer<typeof CommitStatusSchema>> { const response = await githubRequest( github_pat, `https://api.github.com/repos/${owner}/${repo}/statuses/${sha}`, { method: "POST", body: { state, ...options, }, } ); return CommitStatusSchema.parse(response); }
- src/operations/statuses.ts:20-32 (schema)Input schemas for validating tool parameters. CreateCommitStatusSchema is used for tool registration; _CreateCommitStatusSchema (with github_pat) is used for parsing in dispatch.export const CreateCommitStatusSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), sha: z.string().describe("The SHA of the commit to create a status for"), state: z.enum(["error", "failure", "pending", "success"]).describe("The state of the status"), target_url: z.string().optional().describe("The target URL to associate with this status"), description: z.string().optional().describe("A short description of the status"), context: z.string().optional().describe("A string label to differentiate this status from others") }); export const _CreateCommitStatusSchema = CreateCommitStatusSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/index.ts:211-215 (registration)Tool registration in the MCP server's listTools response, including name, description, and input schema reference.{ name: "create_commit_status", description: "Create a status for a commit (build passed/failed, etc.)", inputSchema: zodToJsonSchema(statuses.CreateCommitStatusSchema), },
- src/index.ts:620-627 (registration)Dispatch handler in the MCP server's CallToolRequest that parses arguments and calls the createCommitStatus function.case "create_commit_status": { const args = statuses._CreateCommitStatusSchema.parse(params.arguments); const { github_pat, owner, repo, sha, state, ...options } = args; const result = await statuses.createCommitStatus(github_pat, owner, repo, sha, state, options); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/operations/statuses.ts:6-17 (schema)Output schema used to parse the GitHub API response for the commit status.export const CommitStatusSchema = z.object({ url: z.string(), id: z.number(), node_id: z.string(), state: z.enum(["error", "failure", "pending", "success"]), description: z.string().nullable(), target_url: z.string().nullable(), context: z.string(), created_at: z.string(), updated_at: z.string(), creator: GitHubIssueAssigneeSchema.nullable(), });