watch
Monitor files or directories for changes and block until new events arrive, replacing manual polling loops; manage multiple monitors with start, poll, list, and stop actions.
Instructions
Watch a file or directory for changes. start returns a watch_id; poll blocks up to wait_ms for new events and returns them (so one call replaces a polling loop); list shows active watchers; stop ends one. Events are coalesced per path, so a save that fires three times is reported once.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>"
},
"name": "watch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| glob | No | start: only report paths matching these globs. | |
| path | No | start: file or directory to watch. | |
| clear | No | poll: drop the returned events from the buffer. Default true. | |
| action | Yes | What to do. | |
| exclude | No | start: ignore paths matching these globs. | |
| wait_ms | No | poll: block up to this long for the first event. Default 0 (return at once). | |
| watch_id | No | poll/stop: which watcher. | |
| max_bytes | No | Byte cap on returned output. | |
| recursive | No | start: watch subdirectories. Default true. | |
| settle_ms | No | poll: after the first event, wait this long for related ones before returning. Default 300. |