list_commits
Retrieve a list of commits from a specific branch in a GitHub repository. Specify owner, repo, and optional parameters like SHA, page, and perPage to streamline commit history access.
Instructions
Get list of commits of a branch in a GitHub repository
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | ||
| page | No | ||
| perPage | No | ||
| repo | Yes | ||
| sha | No |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"owner": {
"type": "string"
},
"page": {
"type": "number"
},
"perPage": {
"type": "number"
},
"repo": {
"type": "string"
},
"sha": {
"type": "string"
}
},
"required": [
"owner",
"repo"
],
"type": "object"
}
Implementation Reference
- operations/commits.ts:12-26 (handler)The core handler function that performs the GitHub API request to list commits.export async function listCommits( owner: string, repo: string, page?: number, perPage?: number, sha?: string ) { return githubRequest( buildUrl(`https://api.github.com/repos/${owner}/${repo}/commits`, { page: page?.toString(), per_page: perPage?.toString(), sha }) ); }
- operations/commits.ts:4-10 (schema)Input schema (Zod) for validating tool arguments.export const ListCommitsSchema = z.object({ owner: z.string(), repo: z.string(), sha: z.string().optional(), page: z.number().optional(), perPage: z.number().optional() });
- index.ts:118-122 (registration)Tool registration in the ListTools response, defining name, description, and input schema.{ name: "list_commits", description: "Get list of commits of a branch in a GitHub repository", inputSchema: zodToJsonSchema(commits.ListCommitsSchema) },
- index.ts:335-347 (handler)Dispatcher handler in CallToolRequest that parses arguments and invokes the core handler.case "list_commits": { const args = commits.ListCommitsSchema.parse(request.params.arguments); const results = await commits.listCommits( args.owner, args.repo, args.page, args.perPage, args.sha ); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; }