Skip to main content
Glama

git-analytics

Analyze Git repository statistics, commit history, and contributor activity to gain insights into project development patterns and team contributions.

Instructions

Git analytics and statistics tool for repository analysis. Supports stats, commits, and contributors operations. Provides comprehensive analytics for Git repositories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesThe analytics operation to perform
authorNoFilter commits by author (for commits operation)
branchNoSpecific branch to analyze (default: current branch)
committerNoFilter commits by committer (for commits operation)
excludePathsNoPaths to exclude from analysis
formatNoOutput format for results
grepNoSearch in commit messages (for commits operation)
groupByNoGroup statistics by time period (for stats operation)
includeFileTypesNoInclude file type analysis (for stats operation)
includeMergesNoInclude merge commits in analysis
includePathsNoSpecific paths to include in analysis
includeStatsNoInclude file change statistics (for commits operation)
limitNoMaximum number of results to return
minCommitsNoMinimum commits threshold (for contributors operation)
ownerNoRepository owner (for remote operations)
projectPathYesAbsolute path to the project directory
providerNoProvider for enhanced remote analytics (optional)
refNoSpecific ref to analyze (commit, tag, etc.)
repoNoRepository name (for remote operations)
sinceNoStart date for analysis (ISO date or relative like "1 week ago")
sortByNoSort contributors by field (for contributors operation)
untilNoEnd date for analysis (ISO date or relative like "yesterday")

Implementation Reference

  • Main execute() method in GitAnalyticsTool class that handles all git-analytics operations: validation, routing to local/remote handlers, error handling.
    async execute(params: GitAnalyticsParams): Promise<ToolResult> {
      const startTime = Date.now();
    
      try {
        // Validate basic parameters
        const validation = ParameterValidator.validateToolParams('git-analytics', params);
        if (!validation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Parameter validation failed: ${validation.errors.join(', ')}`,
            params.action,
            { validationErrors: validation.errors },
            validation.suggestions
          );
        }
    
        // Validate operation-specific parameters
        const operationValidation = ParameterValidator.validateOperationParams('git-analytics', params.action, params);
        if (!operationValidation.isValid) {
          return OperationErrorHandler.createToolError(
            'VALIDATION_ERROR',
            `Operation validation failed: ${operationValidation.errors.join(', ')}`,
            params.action,
            { validationErrors: operationValidation.errors },
            operationValidation.suggestions
          );
        }
    
        // Route to appropriate handler
        const isRemoteOperation = this.isRemoteOperation(params.action);
    
        if (isRemoteOperation) {
          if (!params.provider) {
            if (configManager.isUniversalMode()) {
              params.provider = 'both';
              console.error(`[Universal Mode] Auto-applying both providers for ${params.action}`);
            } else {
              return OperationErrorHandler.createToolError(
                'PROVIDER_REQUIRED',
                'Provider parameter is required for remote analytics operations',
                params.action,
                {},
                ['Specify provider as: github, gitea, or both']
              );
            }
          }
          return await this.executeRemoteOperation(params, startTime);
        } else {
          return await this.executeLocalOperation(params, startTime);
        }
    
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return OperationErrorHandler.createToolError(
          'EXECUTION_ERROR',
          `Failed to execute ${params.action}: ${errorMessage}`,
          params.action,
          { error: errorMessage },
          ['Check the error details and try again']
        );
      }
    }
  • Static getToolSchema() method providing the complete input schema for git-analytics tool registration in MCP.
    static getToolSchema() {
      return {
        name: 'git-analytics',
        description: 'Git analytics and statistics tool for repository analysis. Supports stats, commits, and contributors operations. Provides comprehensive analytics for Git repositories.',
        inputSchema: {
          type: 'object',
          properties: {
            action: {
              type: 'string',
              enum: ['stats', 'commits', 'contributors'],
              description: 'The analytics operation to perform'
            },
            projectPath: {
              type: 'string',
              description: 'Absolute path to the project directory'
            },
            provider: {
              type: 'string',
              enum: ['github', 'gitea', 'both'],
              description: 'Provider for enhanced remote analytics (optional)'
            },
            since: {
              type: 'string',
              description: 'Start date for analysis (ISO date or relative like "1 week ago")'
            },
            until: {
              type: 'string',
              description: 'End date for analysis (ISO date or relative like "yesterday")'
            },
            branch: {
              type: 'string',
              description: 'Specific branch to analyze (default: current branch)'
            },
            ref: {
              type: 'string',
              description: 'Specific ref to analyze (commit, tag, etc.)'
            },
            author: {
              type: 'string',
              description: 'Filter commits by author (for commits operation)'
            },
            committer: {
              type: 'string',
              description: 'Filter commits by committer (for commits operation)'
            },
            grep: {
              type: 'string',
              description: 'Search in commit messages (for commits operation)'
            },
            minCommits: {
              type: 'number',
              description: 'Minimum commits threshold (for contributors operation)'
            },
            sortBy: {
              type: 'string',
              enum: ['commits', 'additions', 'deletions', 'name'],
              description: 'Sort contributors by field (for contributors operation)'
            },
            format: {
              type: 'string',
              enum: ['json', 'csv', 'summary'],
              description: 'Output format for results'
            },
            limit: {
              type: 'number',
              description: 'Maximum number of results to return'
            },
            includeStats: {
              type: 'boolean',
              description: 'Include file change statistics (for commits operation)'
            },
            includeMerges: {
              type: 'boolean',
              description: 'Include merge commits in analysis'
            },
            repo: {
              type: 'string',
              description: 'Repository name (for remote operations)'
            },
            groupBy: {
              type: 'string',
              enum: ['day', 'week', 'month', 'year'],
              description: 'Group statistics by time period (for stats operation)'
            },
            includeFileTypes: {
              type: 'boolean',
              description: 'Include file type analysis (for stats operation)'
            },
            includePaths: {
              type: 'array',
              items: { type: 'string' },
              description: 'Specific paths to include in analysis'
            },
            excludePaths: {
              type: 'array',
              items: { type: 'string' },
              description: 'Paths to exclude from analysis'
            }
          },
          required: ['action', 'projectPath']
        }
      };
    }
  • src/server.ts:502-503 (registration)
    Registration in server executeTool switch: routes 'git-analytics' calls to this.gitAnalyticsTool.execute()
    case 'git-analytics':
      return await this.gitAnalyticsTool.execute(args);
  • src/server.ts:109-109 (registration)
    Tool instance initialization in GitMCPServer constructor with provider config.
    this.gitAnalyticsTool = new GitAnalyticsTool(providerConfig);
  • src/server.ts:141-141 (registration)
    Tool schema included in ListToolsRequestHandler response for MCP tool discovery.
    GitAnalyticsTool.getToolSchema(),
  • TOOL_OPERATIONS definition listing supported actions for git-analytics validation.
    'git-analytics': ['stats', 'commits', 'contributors'],
  • REMOTE_OPERATIONS definition indicating git-analytics uses local operations by default.
    'git-analytics': [], // All analytics operations are local by default
Behavior2/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. While it mentions 'comprehensive analytics,' it doesn't describe what the tool actually returns, whether it performs read-only operations, what permissions are required, whether it works on local vs remote repositories, or any performance characteristics. The description is too high-level to guide an agent on what to expect from tool execution.

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 reasonably concise with three sentences, but it's repetitive ('analytics' appears three times, 'Git' twice) and doesn't front-load the most critical information. The first sentence could be more specific about the tool's core function. While not overly verbose, the description doesn't efficiently communicate value beyond the tool name.

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?

For a complex tool with 22 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'comprehensive analytics' means in practice, what format results are returned in, or how the three action types differ in output. The agent would struggle to understand what this tool actually produces when invoked, despite the detailed parameter schema.

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 description coverage is 100%, so the schema already documents all 22 parameters thoroughly. The description adds no parameter-specific information beyond mentioning 'stats, commits, and contributors operations' which loosely maps to the 'action' parameter enum. No additional syntax, format details, or parameter relationships are explained in the description beyond what's already in the schema.

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

Purpose3/5

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

The description states it's a 'Git analytics and statistics tool for repository analysis' which gives a general purpose, but it's vague about what specific analytics are provided. It mentions 'stats, commits, and contributors operations' but doesn't clearly distinguish this from sibling tools like git-branches or git-files that might also provide analytics. The description doesn't specify a clear verb+resource combination beyond 'analysis'.

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 many sibling tools available (git-branches, git-issues, git-pulls, etc.), there's no indication of when analytics operations should be performed through this tool versus others. The description doesn't mention prerequisites, dependencies, or any context for choosing this specific analytics tool.

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/Andre-Buzeli/git-mcp'

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