Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesFile or directory path to watch
patternNoGlob pattern filter (optional)
action_idNoLink events to an agent action

Implementation Reference

  • 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'],
      },

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/jarvisassistantux/loopsense'

If you have feedback or need assistance with the MCP directory API, please join our Discord server