list_commits
Retrieve commit history from a GitHub repository branch to track changes, review code evolution, and analyze development progress.
Instructions
Get list of commits of a branch in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | ||
| repo | Yes | ||
| sha | No | ||
| page | No | ||
| perPage | No |
Implementation Reference
- operations/commits.ts:12-26 (handler)The main handler function that executes the tool logic by making a GitHub API request to list commits in a repository.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)Zod input schema defining parameters for the list_commits tool: owner, repo, optional sha, page, perPage.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:119-122 (registration)Tool registration in the ListTools response, specifying 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 (registration)Dispatch logic in the CallToolRequest handler that parses arguments and invokes the listCommits function.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) }], }; }