Filesystem Watcher MCP
Enables AI coding agents to watch directories for live filesystem changes (create, modify, delete, move) via the Model Context Protocol, providing event-driven access without busy-polling.
README
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
<details> <summary>Antigravity</summary>
To use the Filesystem Watcher MCP server, follow the instructions from <a href="https://antigravity.google/docs/mcp">Antigravity's docs</a> 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"]
}
}
}
</details>
<details> <summary>Claude Code</summary>
Use the Claude Code CLI to add the server (<a href="https://code.claude.com/docs/en/mcp">guide</a>):
claude mcp add filesystemwatcher --scope user uv run python src/server.py
</details>
<details> <summary>Copilot / VS Code</summary>
Follow the MCP install <a href="https://code.visualstudio.com/docs/copilot/chat/mcp-servers#_add-an-mcp-server">guide</a> and use the standard config from above.
</details>
<details> <summary>Cursor</summary>
Go to Cursor Settings -> MCP -> New MCP Server. Use the config provided above.
</details>
<details> <summary>Gemini CLI</summary>
gemini mcp add filesystemwatcher uv run python src/server.py
Alternatively, follow the <a href="https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#how-to-set-up-your-mcp-server">MCP guide</a> and use the standard config from above.
</details>
<details> <summary>Windsurf</summary> Follow the <a href="https://docs.windsurf.com/windsurf/cascade/mcp#mcp-config-json">configure MCP guide</a> using the standard config from above. </details>
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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。