Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

list-commits

Retrieve commit history for a specific branch in a GitHub repository to track code changes and review development progress.

Instructions

Get list of commits of a branch in a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes
pageNo
perPageNo
repoYes
shaNo

Implementation Reference

  • src/server.ts:249-274 (registration)
    Tool registration in the ListToolsRequestHandler, including name, description, and input schema definition.
    {
      name: 'list-commits',
      description: 'Get list of commits of a branch in a GitHub repository',
      inputSchema: {
        type: 'object',
        properties: {
          owner: {
            type: 'string',
          },
          repo: {
            type: 'string',
          },
          sha: {
            type: 'string',
          },
          page: {
            type: 'number',
          },
          perPage: {
            type: 'number',
          },
        },
        required: ['owner', 'repo'],
        additionalProperties: false,
      },
    },
  • The core handler function implementing the list-commits tool. Parses input with ListCommitsSchema, calls GitHub API repos.listCommits, formats and returns commit data.
    export async function listCommits(args: unknown): Promise<any> {
      const { owner, repo, sha, page, perPage } = ListCommitsSchema.parse(args);
      const github = getGitHubApi();
    
      return tryCatchAsync(async () => {
        const { data } = await github.getOctokit().repos.listCommits({
          owner,
          repo,
          sha,
          page,
          per_page: perPage,
        });
    
        return data.map((commit) => ({
          sha: commit.sha,
          commit: {
            author: commit.commit.author,
            committer: commit.commit.committer,
            message: commit.commit.message,
          },
          author: commit.author ? {
            login: commit.author.login,
            id: commit.author.id,
            type: commit.author.type,
          } : null,
          committer: commit.committer ? {
            login: commit.committer.login,
            id: commit.committer.id,
            type: commit.committer.type,
          } : null,
          html_url: commit.html_url,
        }));
      }, 'Failed to list commits');
    }
  • Zod schema for input validation used in the listCommits handler. Extends OwnerRepoSchema with optional sha, page, perPage.
    export const ListCommitsSchema = OwnerRepoSchema.extend({
      sha: z.string().optional(),
      page: z.number().optional(),
      perPage: z.number().optional(),
    });
  • Dispatch case in CallToolRequestHandler switch statement that invokes the listCommits handler.
    case 'list-commits':
      result = await listCommits(parsedArgs);
      break;
  • Import of getGitHubApi helper used to obtain the GitHub Octokit instance.
    import { getGitHubApi } from '../utils/github-api.js';

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

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