Skip to main content
Glama

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
NameRequiredDescriptionDefault
ownerYes
pageNo
perPageNo
repoYes
shaNo

Implementation Reference

  • 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 }) ); }
  • 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) },
  • 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) }], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server