Skip to main content
Glama

hooks_start_watching

Start file system watching to automatically trigger events based on file changes, enabling context-aware coding assistance.

Instructions

Start file system watching for automatic event triggering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternsNoFile patterns to watch (optional, uses defaults if not provided)

Implementation Reference

  • MCP tool handler for 'hooks_start_watching' that starts file system watching by calling HooksService.startFileWatching with optional patterns.
    tools.set('hooks_start_watching', async (args: any) => {
      await hooksService.startFileWatching(args.patterns);
      return { success: true, message: 'File watching started', patterns: args.patterns };
    });
  • Input schema definition for the hooks_start_watching tool, defining optional patterns array.
    {
      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: []
      }
    },
  • src/index.ts:415-417 (registration)
    Top-level registration of hooks tools (including hooks_start_watching) in the main server by invoking registerHooksTools.
    if (this.config.services.hooks && this.hooksService) {
      const hookTools = registerHooksTools(this.tools, this.hooksService);
      this.toolDefinitions.push(...hookTools);
  • Core implementation of file watching using chokidar, setting up event handlers for file changes invoked by the tool handler.
    async startFileWatching(patterns?: string[]): Promise<void> {
      const watchPatterns = patterns || this.config.fileWatch.patterns;
      
      const watcher = this.watcherFactory.watch(watchPatterns, {
        ignored: this.config.fileWatch.ignored,
        persistent: this.config.fileWatch.persistent,
        ignoreInitial: this.config.fileWatch.ignoreInitial,
        cwd: this.projectRoot
      });
    
      watcher
        .on('add', (path) => this.handleFileSystemEvent('add', path))
        .on('change', (path) => this.handleFileSystemEvent('change', path))
        .on('unlink', (path) => this.handleFileSystemEvent('unlink', path))
        .on('error', (error) => console.error('File watcher error:', error));
    
      this.watchers.set('main', watcher);
      await this.notify('system', 'File watching started');
    }

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