Skip to main content
Glama

hooks_setup_git

Configure Git hooks to automate documentation updates and code validation processes within your development workflow.

Instructions

Setup Git hooks for automated documentation and validation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'hooks_setup_git' that invokes HooksService.setupGitHooks() and returns success status.
    tools.set('hooks_setup_git', async () => {
      const gitSetup = await hooksService.setupGitHooks();
      return { success: gitSetup, message: gitSetup ? 'Git hooks setup successfully' : 'Failed to setup Git hooks' };
    });
  • Tool schema definition specifying no input parameters required.
    {
      name: 'hooks_setup_git',
      description: 'Setup Git hooks for automated documentation and validation',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      }
    },
  • Main logic for setting up Git hooks: creates and writes pre-commit and post-commit hook scripts to .git/hooks directory, makes them executable on Unix.
    async setupGitHooks(): Promise<boolean> {
      if (!this.config.gitIntegration) {
        return false;
      }
    
      const hooksDir = this.pathAdapter.join(this.projectRoot, '.git', 'hooks');
      
      if (!this.fileSystem.existsSync(hooksDir)) {
        return false;
      }
    
      try {
        // Create pre-commit hook
        const preCommitHook = this.generatePreCommitHook();
        this.fileSystem.writeFileSync(this.pathAdapter.join(hooksDir, 'pre-commit'), preCommitHook);
    
        // Create post-commit hook
        const postCommitHook = this.generatePostCommitHook();
        this.fileSystem.writeFileSync(this.pathAdapter.join(hooksDir, 'post-commit'), postCommitHook);
    
        // Make hooks executable (Unix systems)
        if (process.platform !== 'win32') {
          this.fileSystem.chmodSync(this.pathAdapter.join(hooksDir, 'pre-commit'), 0o755);
          this.fileSystem.chmodSync(this.pathAdapter.join(hooksDir, 'post-commit'), 0o755);
        }
    
        await this.notify('system', 'Git hooks setup completed');
        return true;
      } catch (error: any) {
        console.error('Failed to setup git hooks:', error);
        return false;
      }
    }
  • Generates the content for the pre-commit Git hook script.
      private generatePreCommitHook(): string {
        return `#!/bin/sh
    # CastPlan Automation Pre-commit Hook
    
    # Get staged files
    changed_files=$(git diff --cached --name-only)
    
    if [ ! -z "$changed_files" ]; then
      echo "๐Ÿ” Running pre-commit hooks..."
      
      # Trigger pre-work event via MCP
      # This would typically call the MCP server
      echo "Files to be committed: $changed_files"
    fi
    `;
      }
  • Generates the content for the post-commit Git hook script.
      private generatePostCommitHook(): string {
        return `#!/bin/sh
    # CastPlan Automation Post-commit Hook
    
    # Get committed files
    changed_files=$(git diff-tree --no-commit-id --name-only -r HEAD)
    commit_message=$(git log -1 --pretty=%B)
    
    if [ ! -z "$changed_files" ]; then
      echo "๐Ÿ“ Running post-commit hooks..."
      
      # Trigger post-work event via MCP
      # This would typically call the MCP server
      echo "Files committed: $changed_files"
      echo "Commit message: $commit_message"
    fi
    `;
      }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool sets up Git hooks but does not explain what that entailsโ€”e.g., whether it modifies existing hooks, requires specific permissions, or has side effects like overwriting files. For a tool that likely modifies system configurations, this lack of detail is a significant gap.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and every part ('Setup Git hooks for automated documentation and validation') contributes essential information, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool has 0 parameters and no output schema, the description is adequate for a basic setup tool. However, it lacks details on behavioral aspects (e.g., what hooks are created, any dependencies) and does not reference sibling tools, leaving gaps in understanding the full context. It meets minimum viability but could be more informative.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description adds value by specifying the purpose ('for automated documentation and validation'), which goes beyond the schema. However, it does not provide additional context like hook types or validation rules, keeping it from a perfect score.

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 tool's purpose: 'Setup Git hooks for automated documentation and validation.' It specifies the verb ('Setup'), resource ('Git hooks'), and intended outcome ('for automated documentation and validation'), making it easy to understand what the tool does. However, it does not explicitly differentiate from sibling tools like 'hooks_start_watching' or 'hooks_trigger', which prevents a score of 5.

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 does not mention prerequisites (e.g., whether Git is initialized), exclusions, or related tools like 'hooks_start_watching' for ongoing monitoring. Without any usage context, the agent must infer when this tool is appropriate.

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/Ghostseller/CastPlan_mcp'

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