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'],
      },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. Mentions 'chokidar' (Node.js watcher library) but fails to disclose: whether this returns immediately or blocks, what it returns (watch ID?), how events are delivered (callback vs polled), or that the watch persists until cancel_watch is called.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence with no filler. Efficiently conveys the core operation and implementation library. However, given the complexity of file watching and lack of annotations/output schema, this extreme brevity leaves critical gaps.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Severely incomplete for a stateful operation with no output schema or annotations. Fails to explain the watch lifecycle, return value (likely a watch handle given cancel_watch sibling), event delivery mechanism (action_id hints at callbacks but is unexplained), or relationship to poll_events and list_watches.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage documenting path, pattern, and action_id. Description adds no parameter syntax, validation rules, or examples beyond what the schema provides, warranting the baseline score for high-coverage schemas.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the verb (Watch), resource (file or directory), and change detection focus. Implicitly distinguishes from siblings like watch_url and watch_process by specifying 'file or directory', though could explicitly mention these alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides no guidance on when to prefer this over watch_process for log files, or when to use poll_events versus setting up a watch. No mention of prerequisites like path existence or permissions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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