Skip to main content
Glama

list_commits

Retrieve commit history for a GitLab project with options to filter by path, date range, SHA, and pagination. Supports detailed commit stats and first-parent history.

Instructions

Get commit history for a GitLab project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allNo
first_parentNo
pageNo
pathNo
per_pageNo
project_idNo
shaNo
sinceNo
untilNo
with_statsNo

Implementation Reference

  • Core handler function in GitLabApi class that fetches and returns commits for a project using the GitLab API.
    async listCommits(
      projectId: string,
      options: {
        sha?: string;
        since?: string;
        until?: string;
        path?: string;
        all?: boolean;
        with_stats?: boolean;
        first_parent?: boolean;
        page?: number;
        per_page?: number;
      } = {}
    ): Promise<GitLabCommitsResponse> {
      const url = new URL(
        `${this.apiUrl}/projects/${encodeURIComponent(
          projectId
        )}/repository/commits`
      );
    
      // Add query parameters for filtering and pagination
      Object.entries(options).forEach(([key, value]) => {
        if (value !== undefined) {
          url.searchParams.append(key, value.toString());
        }
      });
    
      const response = await fetch(url.toString(), {
        headers: {
          Authorization: `Bearer ${this.token}`,
        },
      });
    
      if (!response.ok) {
        throw new McpError(
          ErrorCode.InternalError,
          `GitLab API error: ${response.statusText}`
        );
      }
    
      // Parse the response JSON
      const commits = await response.json();
    
      // Get the total count from the headers
      const totalCount = parseInt(response.headers.get("X-Total") || "0");
    
      // Validate and return the response
      return GitLabCommitsResponseSchema.parse({
        count: totalCount,
        items: commits,
      });
    }
  • MCP server tool handler case for 'list_commits' that validates input, calls GitLabApi.listCommits, and formats the response.
    case "list_commits": {
      // Parse and validate the arguments
      const args = ListCommitsSchema.parse(request.params.arguments);
    
      // Additional validation for pagination parameters
      if (args.per_page && (args.per_page < 1 || args.per_page > 100)) {
        throw new Error("per_page must be between 1 and 100");
      }
    
      if (args.page && args.page < 1) {
        throw new Error("page must be greater than 0");
      }
    
      // Validate date formats if provided
      if (args.since && !isValidISODate(args.since)) {
        throw new Error(
          "since must be a valid ISO 8601 date (YYYY-MM-DDTHH:MM:SSZ)"
        );
      }
    
      if (args.until && !isValidISODate(args.until)) {
        throw new Error(
          "until must be a valid ISO 8601 date (YYYY-MM-DDTHH:MM:SSZ)"
        );
      }
    
      // Extract project_id and options
      const { project_id, ...options } = args;
    
      // Call the API function
      const commits = await gitlabApi.listCommits(project_id, options);
    
      // Format and return the response
      return formatCommitsResponse(commits);
    }
  • Zod schema defining the input parameters for the list_commits tool.
    export const ListCommitsSchema = z.object({
      project_id: z.string(),
      sha: z.string().optional(),
      since: z.string().optional(),
      until: z.string().optional(),
      path: z.string().optional(),
      all: z.boolean().optional(),
      with_stats: z.boolean().optional(),
      first_parent: z.boolean().optional(),
      page: z.number().optional(),
      per_page: z.number().optional()
    });
  • src/index.ts:175-178 (registration)
    Tool registration in the ALL_TOOLS array, including name, description, input schema, and read-only flag.
    name: "list_commits",
    description: "Get commit history for a GitLab project",
    inputSchema: createJsonSchema(ListCommitsSchema),
    readOnly: true
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides almost none. It doesn't indicate whether this is a read-only operation, what permissions are required, whether results are paginated, what format the commit history returns, or any rate limits. The single sentence offers no behavioral context beyond the basic purpose.

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 extremely concise at just 7 words, front-loading the essential purpose without any wasted words. Every word earns its place, making it efficient for quick scanning while communicating the core function.

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

Completeness1/5

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

For a tool with 10 undocumented parameters, no annotations, and no output schema, the description is completely inadequate. It provides only the most basic purpose statement without addressing the complexity of parameter usage, behavioral characteristics, or output format. The description doesn't meet the minimum requirements for such a complex tool.

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

Parameters1/5

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

With 10 parameters and 0% schema description coverage, the description provides no information about any parameters. It doesn't explain what 'project_id' should contain, how 'since' and 'until' should be formatted, what 'with_stats' includes, or any other parameter meaning. The description fails completely to compensate for the schema's lack of documentation.

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 commit history') and target resource ('for a GitLab project'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from potential alternatives like 'get_project_events' or explain what makes commit history distinct from other project activity logs.

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. With sibling tools like 'get_project_events' that might overlap in functionality, there's no indication of when commit history is the appropriate choice versus other project activity tracking methods.

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/yoda-digital/mcp-gitlab-server'

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