watch_file
Monitor files or directories for real-time changes, enabling AI coding agents to detect modifications and trigger automated responses.
Instructions
Watch a file or directory for changes using chokidar
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File or directory path to watch | |
| pattern | No | Glob pattern filter (optional) | |
| action_id | No | Link events to an agent action |
Implementation Reference
- src/server.ts:324-345 (handler)Implementation of the watch_file tool handler.
private async handleWatchFile(args: Record<string, unknown>) { const schema = z.object({ path: z.string(), pattern: z.string().optional(), action_id: z.string().optional(), }); const parsed = schema.parse(args); const id = uuidv4(); const now = new Date().toISOString(); const config: FileConfig = { kind: 'file', path: parsed.path, pattern: parsed.pattern }; const watch: WatchRecord = { id, kind: 'file', config, action_id: parsed.action_id ?? null, created_at: now, active: true, last_poll_at: null, }; insertWatch(watch); - src/server.ts:85-96 (registration)Tool registration for watch_file in the server list.
{ name: 'watch_file', description: 'Watch a file or directory for changes using chokidar', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File or directory path to watch' }, pattern: { type: 'string', description: 'Glob pattern filter (optional)' }, action_id: { type: 'string', description: 'Link events to an agent action' }, }, required: ['path'], },