Skip to main content
Glama
jonmatum

Git Metrics MCP Server

by jonmatum

get_conventional_commits

Analyze conventional commit usage and release patterns in a git repository by specifying a date range.

Instructions

Analyze conventional commit usage and release patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYesPath to git repository
sinceYesStart date (YYYY-MM-DD)
untilNoEnd date (YYYY-MM-DD), optional

Implementation Reference

  • The main handler function that executes the 'get_conventional_commits' tool logic. It validates inputs, runs git log to parse conventional commits (feat, fix, docs, etc.), extracts types/scopes/breaking changes, also retrieves release tags, and returns structured results.
    export function handleGetConventionalCommits(args: any) {
      const { repo_path, since, until } = args;
      
      validateRepoPath(repo_path);
      validateDate(since, "since");
      if (until) validateDate(until, "until");
      
      let cmd = `git log --since="${since}"`;
      if (until) cmd += ` --until="${until} 23:59:59"`;
      cmd += ` --pretty=format:"%H|%s|%ad" --date=short`;
      const output = runGitCommand(repo_path, cmd);
      const lines = output.trim().split("\n").filter(l => l);
      
      const types: Record<string, number> = {};
      const scopes: Record<string, number> = {};
      let breaking = 0;
      let conventional = 0;
      
      const conventionalRegex = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(([^)]+)\))?(!)?:/;
      
      for (const line of lines) {
        const [, message] = line.split("|");
        const match = message.match(conventionalRegex);
        
        if (match) {
          conventional++;
          const [, type, , scope, isBreaking] = match;
          types[type] = (types[type] || 0) + 1;
          if (scope) scopes[scope] = (scopes[scope] || 0) + 1;
          if (isBreaking || message.includes("BREAKING CHANGE")) breaking++;
        }
      }
      
      const tagsCmd = `git tag --sort=-creatordate --format="%(refname:short)|%(creatordate:short)"`;
      const tagsOutput = runGitCommand(repo_path, tagsCmd);
      const tags = tagsOutput.trim().split("\n").filter(t => t);
      
      const releases = tags
        .map(t => {
          const [tag, date] = t.split("|");
          return { tag, date };
        })
        .filter(r => {
          const releaseDate = new Date(r.date);
          const sinceDate = new Date(since);
          const untilDate = until ? new Date(until) : new Date();
          return releaseDate >= sinceDate && releaseDate <= untilDate;
        });
      
      const sortedScopes = Object.entries(scopes).sort(([,a], [,b]) => b - a);
      
      return {
        totalCommits: lines.length,
        conventionalCommits: conventional,
        conventionalPercentage: `${((conventional / lines.length) * 100).toFixed(1)}%`,
        commitTypes: Object.entries(types).sort(([,a], [,b]) => b - a).map(([type, count]) => ({ type, count })),
        topScopes: sortedScopes.slice(0, 10).map(([scope, count]) => ({ scope, count })),
        totalScopeCount: sortedScopes.length,
        breakingChanges: breaking,
        recentReleases: releases,
        totalReleasesCount: releases.length,
        releaseFrequency: releases.length > 1 ? `${releases.length} releases since ${since}` : "No releases found"
      };
    }
  • Tool schema definition for 'get_conventional_commits' in the ListToolsRequestHandler. Defines input parameters: repo_path (required), since (required YYYY-MM-DD), until (optional YYYY-MM-DD).
    {
      name: "get_conventional_commits",
      description: "Analyze conventional commit usage and release patterns",
      inputSchema: {
        type: "object",
        properties: {
          repo_path: { type: "string", description: "Path to git repository" },
          since: { type: "string", description: "Start date (YYYY-MM-DD)" },
          until: { type: "string", description: "End date (YYYY-MM-DD), optional" },
        },
        required: ["repo_path", "since"],
      },
    },
  • Registration of the tool handler in the CallToolRequestSchema handler chain. Maps the tool name 'get_conventional_commits' to the handler function handlers.handleGetConventionalCommits(args).
    } else if (request.params.name === "get_conventional_commits") {
      result = handlers.handleGetConventionalCommits(args);
  • The validateDate helper function used by the handler to validate date parameters are in YYYY-MM-DD format.
    export function validateDate(date: string, fieldName: string): void {
      if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
        throw new Error(`Invalid ${fieldName} format. Use YYYY-MM-DD (e.g., 2025-11-21)`);
      }
    }
  • The validateRepoPath helper function used by the handler to validate that the repo_path exists and is a valid git repository.
    export function validateRepoPath(repoPath: string): void {
      if (!repoPath || typeof repoPath !== 'string') {
        throw new Error('repo_path is required and must be a string');
      }
      if (/[;&|`$()]/.test(repoPath)) {
        throw new Error('Invalid characters in repo_path');
      }
      const fullPath = resolve(repoPath);
      if (!existsSync(fullPath)) {
        throw new Error(`Repository path does not exist: ${fullPath}`);
      }
      const gitPath = resolve(fullPath, '.git');
      if (!existsSync(gitPath)) {
        throw new Error(`Not a git repository: ${fullPath}`);
      }
    }
Behavior2/5

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

No annotations are provided, so the description must disclose behavior. It only mentions analysis of commits but lacks details on side effects, read-only access, or data sources. Minimal transparency.

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

Conciseness3/5

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

The description is very short and front-loaded, but it sacrifices necessary detail. It achieves conciseness at the expense of completeness, earning an average score.

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?

Lacking output schema and annotations, the description does not clarify return values, filtering behavior, or examples. It leaves significant gaps for an analysis tool with multiple parameters.

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

Parameters3/5

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

Schema coverage is 100% with clear descriptions for each parameter. The tool description adds no extra meaning beyond the schema, so baseline score of 3 is appropriate.

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 states the tool analyzes conventional commit usage and release patterns, aligning with the tool name. However, it does not differentiate from sibling tools like get_commit_patterns, leaving some ambiguity about its unique focus.

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?

No guidance on when to use this tool versus alternatives or any context about prerequisites or exclusions. The description is too brief to inform usage decisions.

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

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/jonmatum/git-metrics-mcp-server'

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