Skip to main content
Glama

list_commits

Retrieve a list of commits from a specific branch in a GitHub repository. Input repository owner, repo name, and branch SHA to access detailed commit history.

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 logic to fetch commits from the GitHub API for the 'list_commits' tool.
    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 }) ); }
  • Input schema for validating arguments to the 'list_commits' tool.
    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:115-119 (registration)
    Tool registration in the MCP server's list of tools, including name, description, and input schema.
    { name: "list_commits", description: "Get list of commits of a branch in a GitHub repository", inputSchema: zodToJsonSchema(commits.ListCommitsSchema) },
  • Dispatch handler in the main CallToolRequestSchema that parses input and calls 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) }], }; }
  • Output schema defining the structure of the commits list returned by the GitHub API.
    export const GitHubListCommitsSchema = z.array(z.object({ sha: z.string(), node_id: z.string(), commit: z.object({ author: GitHubAuthorSchema, committer: GitHubAuthorSchema, message: z.string(), tree: z.object({ sha: z.string(), url: z.string() }), url: z.string(), comment_count: z.number(), }), url: z.string(), html_url: z.string(), comments_url: z.string() }));

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/tuanle96/mcp-github'

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