create_commit_status
Set commit statuses (success, failure, pending, error) in GitHub repositories to track build results and deployment states.
Instructions
Create a status for a commit (build passed/failed, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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 | |
| description | No | A short description of the status | |
| context | No | A string label to differentiate this status from others |
Implementation Reference
- src/operations/statuses.ts:55-79 (handler)Core handler function that executes the tool logic: sends POST request to GitHub API to create a commit status and parses the response.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-28 (schema)Input schema definition for the create_commit_status tool (used in tool registration).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") });
- src/operations/statuses.ts:30-32 (schema)Extended input schema including github_pat (used for parsing arguments in the dispatcher).export const _CreateCommitStatusSchema = CreateCommitStatusSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/index.ts:212-215 (registration)Tool registration in the list_tools handler, defining name, description, and input schema.name: "create_commit_status", description: "Create a status for a commit (build passed/failed, etc.)", inputSchema: zodToJsonSchema(statuses.CreateCommitStatusSchema), },
- src/index.ts:620-627 (handler)Dispatcher case in the main CallToolRequest handler that parses args and delegates to the core implementation.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) }], }; }