Skip to main content
Glama

hooks_trigger

Manually trigger hook events like pre-work, post-work, or file-change to integrate with CastPlan MCP's project memory system.

Instructions

Trigger a hook event manually

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventTypeYesType of hook event to trigger
dataYesEvent data payload

Implementation Reference

  • The handler function for the 'hooks_trigger' tool. It constructs a hook event from the input arguments and delegates processing to the HooksService.
    tools.set('hooks_trigger', async (args: any) => {
      return await hooksService.processHookRequest({
        event: {
          type: args.eventType,
          data: args.data,
          timestamp: new Date().toISOString()
        }
      });
    });
  • Input schema definition for the 'hooks_trigger' tool, specifying required eventType (enum) and data object.
    {
      name: 'hooks_trigger',
      description: 'Trigger a hook event manually',
      inputSchema: {
        type: 'object',
        properties: {
          eventType: {
            type: 'string',
            enum: ['pre-work', 'post-work', 'file-change', 'session-start', 'session-end'],
            description: 'Type of hook event to trigger'
          },
          data: {
            type: 'object',
            description: 'Event data payload',
            additionalProperties: true
          }
        },
        required: ['eventType', 'data']
      }
    },
  • The registerHooksTools function defines and registers the hooks_trigger tool (schema and handler) along with other hooks tools.
    export function registerHooksTools(
      tools: Map<string, Function>,
      hooksService: HooksService
    ): MCPTool[] {
      // Tool definitions
      const hooksTools: MCPTool[] = [
        {
          name: 'hooks_trigger',
          description: 'Trigger a hook event manually',
          inputSchema: {
            type: 'object',
            properties: {
              eventType: {
                type: 'string',
                enum: ['pre-work', 'post-work', 'file-change', 'session-start', 'session-end'],
                description: 'Type of hook event to trigger'
              },
              data: {
                type: 'object',
                description: 'Event data payload',
                additionalProperties: true
              }
            },
            required: ['eventType', 'data']
          }
        },
        {
          name: 'hooks_setup_git',
          description: 'Setup Git hooks for automated documentation and validation',
          inputSchema: {
            type: 'object',
            properties: {},
            required: []
          }
        },
        {
          name: 'hooks_start_watching',
          description: 'Start file system watching for automatic event triggering',
          inputSchema: {
            type: 'object',
            properties: {
              patterns: {
                type: 'array',
                items: { type: 'string' },
                description: 'File patterns to watch (optional, uses defaults if not provided)'
              }
            },
            required: []
          }
        },
        {
          name: 'hooks_stop_watching',
          description: 'Stop file system watching',
          inputSchema: {
            type: 'object',
            properties: {},
            required: []
          }
        }
      ];
      
      // Register tool handlers
      tools.set('hooks_trigger', async (args: any) => {
        return await hooksService.processHookRequest({
          event: {
            type: args.eventType,
            data: args.data,
            timestamp: new Date().toISOString()
          }
        });
      });
      
      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' };
      });
      
      tools.set('hooks_start_watching', async (args: any) => {
        await hooksService.startFileWatching(args.patterns);
        return { success: true, message: 'File watching started', patterns: args.patterns };
      });
      
      tools.set('hooks_stop_watching', async () => {
        await hooksService.stopFileWatching();
        return { success: true, message: 'File watching stopped' };
      });
      
      return hooksTools;
    }
  • src/index.ts:415-417 (registration)
    Top-level registration call in the main server class, which invokes registerHooksTools to add the hooks_trigger tool to the global tools map and definitions.
    if (this.config.services.hooks && this.hooksService) {
      const hookTools = registerHooksTools(this.tools, this.hooksService);
      this.toolDefinitions.push(...hookTools);

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