MCP Observer Server
A file monitoring server that tracks filesystem events and provides real-time notifications to AI assistants, enabling them to automatically respond to file changes without manual updates.
README
mcp-observer-server
mcp-observer-server is an MCP (Model Context Protocol) server that monitors file system events and provides real-time notifications to MCP clients. It acts as a (more bi-directional) bridge between your local file system and AI assistants like Claude Inspector, enabling them to respond to file changes automatically.
NOTE: This is a demo/POC of a file monitoring MCP server that I'm working on. I'm seeing a lot of questions/comments/Issues/Discussions about this kind of thing, so I wanted to post this minimal implementation to share my approach.
Context
The MCP protocol defines the notion of a resource subscription, wherein a client can request to be notified of any changes to a resource, and the server can choose to send notifications. Here is the flow diagram:

The protocol says the client should then send a read request back to the server to read the changes. (All of this is optional, by the way). But, I find this a bit cumbersome, and involves an extra trip, and I'd rather have my resource-update notification describe the change as well. Fortunately, the SDK offers a meta/_meta field and you can pretty much send whatever you want. So I might want to send the number of lines changed, a diff of the changes, who knows what. I haven't implemented that in this demo, right now I'm just sending the timestamp. (I basically ripped everything out from the server except the minimum POC.) Also, it's just running on stdio transport, nothing fancy.
NOTE!!! I haven't tested this with any "real" MCP clients yet - my understanding is that very view clients actually support resource subscriptions, since it's optional anyway. However, fortunately Inspector is a very good client, and you can use that to test this server.
DEMO INSTRUCTIONS:
- Clone the repository.
- Install the dependencies using
uv(or, some other way I suppose). - Run the server using
make start(usesuv) or runnpx @modelcontextprotocol/inspector uv run src/mcp_observer_server/server.py. - Open the Inspector client and connect using stdio, no configuration needed.
- Use the
subscribetool to monitor a directory or file, (alternatively, you can run "List Resources", click a resource, and then click "Subscribe" button to subscribe to it). - By default, the server will expose a file called
watched.txtinsrc/mcp_observer_server/watched.txt(the file is .gitignored, so you have to create it), but you can subscribe to other files as well. You can subscribe this file with thesubscribe_defaulttool. - Modify the
watched.txtfile (or whatever file you subscribed to), and you should see a server notification appear in the bottom-right panel of the Inspector. This is the POC established.
DEMO VISUALIZATION
- Start the server and connect with Inspector:

- List the default resources:

- List the tools:

- Subscribe to the default file:

- Modify the file:

- See the notification appear:

🎉
Server Description
The MCP Observer Server tracks file and directory changes on your system, allowing MCP clients to subscribe to these events and take action when files are created, modified, deleted, or moved (current demo handles modification event). This server implements the full Model Context Protocol specification, providing:
- Real-time file monitoring: Using the Watchdog library for efficient file system observation
- Subscription management: Create, list, and cancel monitoring subscriptions for any path
- Change history: Maintains a log of recent changes for each subscription (omitted in demo)
- File and directory access: Read file contents and directory listings through MCP resources
- Stateless design: Clients control what happens in response to file changes
Key Features
- Subscribe to changes in specific files, directories, or entire repositories
- Filter events by file patterns or event types (omitted in demo)
- Query recent changes to see what files were affected (omitted in demo)
- Access file contents via resource endpoints
- Lightweight and efficient implementation with minimal dependencies
- Simple integration with any MCP-compatible client (...that support resource subscriptions)
Practical Applications
The main pain point I am trying to solve is that unless Claude Code, e.g., touches a file and writes the change to it itself, it has no idea what is going on in your repo/project. (You know those notifications - "File changeed since last read"?) Having a client or coding assistant that is actually monitoring what you're doing in your project and you don't have to delegate every task to Claude just so that it knows that it happens, seems tremendously useful to me. Some practical applications include:
- Automated documentation updates: Keep documentation in sync with code changes - you update some code, Claude is notified of the change, and it pro-actively checks or updates the doc-strings, etc.
- Live code reviews: Get real-time feedback on code changes as you work, catching spelling errors, type errors, etc., giving advice, true pair programming.
- Testing automation: Run tests when relevant files are modified.
- AI assistance: Enable AI tools to respond to file changes automatically.
- Git commit automation: Do you forget to commit frequently enough? Claude can watch your changes and suggest (or perform) commit actions more frequently.
Current Implementation Design
The server implementation features a streamlined architecture that prioritizes simplicity, reliability, and maintainability.
Architecture Highlights
-
Simplified Structure
- Focused implementation (~170 lines of code)
- Consolidated functionality into a small set of core components
- Clean function-based design that leverages the MCP SDK directly
- High readability and maintainability
-
Efficient State Management
- Simple dictionary structure maps paths to client sessions
- Uses a
watcheddictionary for direct path-to-session mapping - Minimal state tracking with clear data flow
- Avoids redundant data structures
-
MCP Protocol Integration
- Direct use of MCP SDK function decorators
- Clean resource URI handling
- Simplified server initialization with proper capability configuration
- Direct notification delivery system
-
Event Processing
- Streamlined Watchdog event handler implementation
- Direct event-to-notification path
- Thread-safe communication via
call_soon_threadsafe - Efficient event filtering
-
Notification System
- Direct use of MCP notification primitives
- Reliable delivery with proper error handling
- Accurate UTC timestamp handling
- Clean URI formatting
Core Components
-
Data Structure
- Single global dictionary
watchedmaps Path objects to sets of ServerSession objects - Each path entry contains the set of sessions subscribed to that path
- Single global dictionary
-
Tool API
- Two essential tools:
subscribeandunsubscribe - Simple path parameter for straightforward subscription management
- Clean error handling and path validation
- Two essential tools:
-
Resource Handling
- File URIs directly exposed through resource listing
- Path resolution and validation
- Text content reading for files
-
Event Processing
- Watcher class extends FileSystemEventHandler
- Processes modified events directly
- Thread-safe notification dispatching
- Path relativity handling for nested paths
-
Notification Delivery
- ServerNotification creation and sending
- Event metadata with timestamps
- Clean URI formatting
The implementation achieves a good balance between functionality and simplicity, resulting in a reliable and maintainable codebase.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。