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()
    }));
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't describe whether this is a read-only operation (implied but not stated), pagination behavior (though parameters suggest it), rate limits, authentication requirements, or what the return format looks like. The description merely restates the basic function without adding behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary words. Every word earns its place, making it easy to parse quickly. No structural issues or redundancy are present.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no annotations, no output schema), the description is inadequate. It doesn't explain parameter usage, behavioral traits like pagination or authentication, or what the output contains. For a tool with multiple parameters and no structured guidance, more descriptive context is needed to help the agent use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter information beyond what's inferable from the tool name. It doesn't explain what 'owner', 'repo', 'sha', 'page', or 'perPage' mean, their expected formats, or how they interact (e.g., that 'sha' specifies the branch). The description fails to provide semantic context for any of the 5 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get list') and target resource ('commits of a branch in a GitHub repository'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_pull_requests' or 'list_issues', which would require mentioning it's specifically for commit history rather than other repository elements.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication needs), when not to use it, or how it compares to similar listing tools in the sibling set. The agent must infer usage purely from the tool name and parameters.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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