list_commits
Retrieve commit history from GitHub repositories to track changes, review code evolution, and analyze development activity for any branch.
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
- src/operations/commits.ts:16-32 (handler)The core handler function for the 'list_commits' tool. It constructs the GitHub API URL for listing commits and makes the authenticated request using githubRequest and buildUrl helpers.export async function listCommits( github_pat: string, owner: string, repo: string, page?: number, perPage?: number, sha?: string ) { return githubRequest( github_pat, buildUrl(`https://api.github.com/repos/${owner}/${repo}/commits`, { page: page?.toString(), per_page: perPage?.toString(), sha }) ); }
- src/operations/commits.ts:4-10 (schema)Input schema for list_commits tool (without github_pat, which is added separately).export const ListCommitsSchema = z.object({ owner: z.string(), repo: z.string(), sha: z.string().optional(), page: z.number().optional(), perPage: z.number().optional() });
- src/operations/commits.ts:12-14 (schema)Extended input schema including the required github_pat for internal parsing.export const _ListCommitsSchema = ListCommitsSchema.extend({ github_pat: z.string() });
- src/index.ts:123-127 (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) },
- src/index.ts:509-522 (registration)Dispatch handler in CallToolRequest that parses arguments and invokes the listCommits function.case "list_commits": { const args = commits._ListCommitsSchema.parse(params.arguments); const results = await commits.listCommits( args.github_pat, args.owner, args.repo, args.page, args.perPage, args.sha ); return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }], }; }