hooks_start_watching
Initiate file system monitoring to automatically trigger events based on specified file patterns, enhancing context-aware project automation in CastPlan MCP.
Instructions
Start file system watching for automatic event triggering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| patterns | No | File patterns to watch (optional, uses defaults if not provided) |
Implementation Reference
- src/tools/hooks/index.ts:85-88 (handler)MCP tool handler implementation for 'hooks_start_watching'. 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 }; });
- src/tools/hooks/index.ts:43-57 (schema)Tool schema definition including name, description, and input schema for 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/services/HooksService.ts:303-321 (helper)Core helper method implementing file watching using chokidar. Sets up watchers for file events (add, change, unlink), configures options, and handles events by processing HookEvents.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'); }
- src/index.ts:415-417 (registration)Top-level registration of all hooks tools (including 'hooks_start_watching') in the main MCP server by invoking registerHooksTools and adding to toolDefinitions.if (this.config.services.hooks && this.hooksService) { const hookTools = registerHooksTools(this.tools, this.hooksService); this.toolDefinitions.push(...hookTools);