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 `; }

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