An event-driven file system watcher for AI agents via the Model Context Protocol (MCP).
Project description
Filesystem Watcher MCP
filesystemwatcher-mcp lets your AI coding agent (Gemini, Claude, Cursor, Copilot, etc.)
watch directories for live file-system changes. It acts as a
Model Context Protocol (MCP) server, giving your
agent event-driven access to file creations, modifications, deletions, and moves —
without busy-polling.
Key features
- Event-driven file watching: Uses Watchdog for cross-platform native OS events (
inotify,FSEvents,ReadDirectoryChangesW). - Safe by design: Blocks watching system-critical paths on Windows, macOS, and Linux. Strict path guardrails are enforced server-side.
- Flexible filtering: Filter events by file extension, glob pattern, or event type (
created,modified,deleted,moved). - Debounced events: Rapid successive events on the same file are coalesced over a 500 ms window — no duplicate noise.
- Consume-once semantics:
poll_eventsdrains the queue, making it easy to integrate into agent loops. - Explicit error surfacing: All failure modes (permission denied, OS backend crash, watch limit) return structured
{"success": false, "error": "..."}responses rather than crashing silently.
Requirements
Getting started
Add the following config to your MCP client:
{
"mcpServers": {
"filesystemwatcher": {
"command": "uv",
"args": ["run", "python", "src/server.py"]
}
}
}
[!NOTE] Make sure you have cloned the repository and installed dependencies (
uv sync) before pointing your MCP client at the server.
MCP Client configuration
Antigravity
To use the Filesystem Watcher MCP server, follow the instructions from Antigravity's docs to install a custom MCP server. Add the following config to the MCP servers config:
{
"mcpServers": {
"filesystemwatcher": {
"command": "uv",
"args": ["run", "python", "src/server.py"]
}
}
}
Claude Code
Use the Claude Code CLI to add the server (guide):
claude mcp add filesystemwatcher --scope user uv run python src/server.py
Copilot / VS Code
Follow the MCP install guide and use the standard config from above.
Cursor
Go to Cursor Settings -> MCP -> New MCP Server. Use the config provided above.
Gemini CLI
gemini mcp add filesystemwatcher uv run python src/server.py
Alternatively, follow the MCP guide and use the standard config from above.
Windsurf
Follow the configure MCP guide using the standard config from above.Your first prompt
Enter the following prompt in your MCP client to check if everything is working:
Watch my home directory for any new file creations and tell me when something appears.
Your agent should call watch_directory and then periodically call poll_events to report changes.
Tools
- File system watching (4 tools)
watch_directory
Start watching a directory for file system events. Returns a watch_id used to identify this watch session.
| Argument | Type | Default | Description |
|---|---|---|---|
path |
str |
required | Absolute path to the directory to watch |
recursive |
bool |
false |
Also watch all subdirectories |
extensions |
list[str] |
null |
Filter by extension, e.g. [".py", ".js"] |
pattern |
str |
null |
Glob pattern matched against file name, e.g. "*.log" |
ignore_patterns |
list[str] |
null |
Glob patterns to exclude, e.g. ["*.tmp", ".git/*"] |
event_types |
list[str] |
null |
Subset of ["created", "modified", "deleted", "moved"] |
Error responses — on failure success is false and error explains why:
| Condition | Example error |
|---|---|
| Path blocked by safety guardrails | "Watching '/etc' is not allowed: protected system location." |
| Process lacks read permission | "Permission denied: cannot watch '/protected'. Check read access." |
| OS watcher backend failed to start | "Filesystem observer failed to start for '...'. Backend may be unavailable." |
| Concurrent watch limit reached | "Watch limit reached (50 active watches). Call unwatch() first." |
poll_events
Drain and return queued file system events (consume-once semantics).
| Argument | Type | Default | Description |
|---|---|---|---|
watch_id |
str |
null |
Filter events by watch ID; if omitted, all watches are drained |
max_events |
int |
50 |
Maximum events to return (1–500) |
If watch_id is provided but does not match any active watch, the response includes a warning field to prevent agents from silently spinning on a stale ID:
{
"count": 0,
"events": [],
"warning": "No active watch found with id 'abc-123'. Use list_active_watches to see current watch IDs."
}
list_active_watches
Return a summary of all currently active watches.
unwatch
Stop and remove a watch by watch_id.
Configuration
The server currently has no command-line flags; all configuration is done via the tool arguments at runtime.
You can inspect available tools interactively with the MCP Inspector:
npx @modelcontextprotocol/inspector mcp dev src/server.py
Safety guardrails
The server blocks watching dangerous system paths:
| Platform | Blocked (exact) | Blocked (subtree) |
|---|---|---|
| Windows | C:\ |
C:\Windows, C:\Program Files, C:\ProgramData |
| Linux | / |
/etc, /sys, /proc, /usr, /dev, /boot, … |
| macOS | / |
/System, /Library, /usr, /private, … |
Watching C:\Users or /home directly is also blocked; individual user home directories are allowed.
Concurrent watch limit: A maximum of 50 active watches are allowed at any time to prevent exhausting the OS inotify quota. Call unwatch to free a slot before creating a new one.
[!WARNING] The MCP server exposes file-system event data to MCP clients. Avoid watching directories that contain sensitive or personal data you would not want shared with your AI agent.
Debouncing
Events are coalesced over a 500 ms window per (event_type, path) key. Rapid
successive events on the same file (e.g. multiple writes during a save) are
reported as a single event.
Development
# Clone and install dependencies
git clone https://github.com/your-org/filesystemwatcher-mcp
cd filesystemwatcher-mcp
uv sync
# Run the server directly
uv run python src/server.py
# Run with MCP Inspector
npx @modelcontextprotocol/inspector mcp dev src/server.py
# Run tests
uv run pytest
# Security audit
uv run pip-audit
Known limitations
- Only local file systems are supported; network mounts may not deliver native OS events reliably.
- The server must be restarted to pick up changes to ignored/blocked path configuration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filesystemwatcher_mcp-0.1.5.tar.gz.
File metadata
- Download URL: filesystemwatcher_mcp-0.1.5.tar.gz
- Upload date:
- Size: 129.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
022c23ed96c2a17103971a3fd323a94720e9273eb5f989f20cf95fefd95e2f0e
|
|
| MD5 |
aa8f1b40b6866bd02183d19363d00186
|
|
| BLAKE2b-256 |
14a1a363dc53b836424d981d88869a5358056e0ae6f9a61455cdd43bfdbd97c3
|
Provenance
The following attestation bundles were made for filesystemwatcher_mcp-0.1.5.tar.gz:
Publisher:
publish.yml on trycatchkamal/filesystemwatcher-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
filesystemwatcher_mcp-0.1.5.tar.gz -
Subject digest:
022c23ed96c2a17103971a3fd323a94720e9273eb5f989f20cf95fefd95e2f0e - Sigstore transparency entry: 1057321609
- Sigstore integration time:
-
Permalink:
trycatchkamal/filesystemwatcher-mcp@4401b34e9346ebfc541d41e7649e74b518f6c090 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/trycatchkamal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4401b34e9346ebfc541d41e7649e74b518f6c090 -
Trigger Event:
push
-
Statement type:
File details
Details for the file filesystemwatcher_mcp-0.1.5-py3-none-any.whl.
File metadata
- Download URL: filesystemwatcher_mcp-0.1.5-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
422e504b93a9560b0f4ed82fa2c366cbc6bcdf4c0d209624572d5e8abf80bfd6
|
|
| MD5 |
c358c23b0d6333da0f8985dada4f72db
|
|
| BLAKE2b-256 |
f797f0be36a7b4d0e47f2f1cd09e406b3cb81f5b2f2511d0dd03a0bcdcb3e804
|
Provenance
The following attestation bundles were made for filesystemwatcher_mcp-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on trycatchkamal/filesystemwatcher-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
filesystemwatcher_mcp-0.1.5-py3-none-any.whl -
Subject digest:
422e504b93a9560b0f4ed82fa2c366cbc6bcdf4c0d209624572d5e8abf80bfd6 - Sigstore transparency entry: 1057321611
- Sigstore integration time:
-
Permalink:
trycatchkamal/filesystemwatcher-mcp@4401b34e9346ebfc541d41e7649e74b518f6c090 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/trycatchkamal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4401b34e9346ebfc541d41e7649e74b518f6c090 -
Trigger Event:
push
-
Statement type: