list_commits
Retrieve a list of commits for a specific branch in a GitHub repository by providing the owner, repo, and optional parameters like SHA, page, or perPage. Use this tool to track and analyze repository changes.
Instructions
Get list of commits of a branch in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | ||
| page | No | ||
| perPage | No | ||
| repo | Yes | ||
| sha | No |
Implementation Reference
- src/operations/commits.ts:16-32 (handler)The core handler function that executes the GitHub API request to list commits in a repository.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-14 (schema)Zod input schemas: ListCommitsSchema (public inputs) and _ListCommitsSchema (includes github_pat for internal use).export const ListCommitsSchema = z.object({ owner: z.string(), repo: z.string(), sha: z.string().optional(), page: z.number().optional(), perPage: z.number().optional() }); export const _ListCommitsSchema = ListCommitsSchema.extend({ github_pat: z.string() });
- src/index.ts:123-127 (registration)Registers the list_commits tool in the MCP server's ListTools response with 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 (handler)MCP server handler case that parses arguments with _ListCommitsSchema and calls the listCommits implementation.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) }], }; }