
Observer
STDIOMCP server monitoring file system events and providing real-time notifications to clients.
MCP server monitoring file system events and providing real-time notifications to clients.
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.
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:
uv
(or, some other way I suppose).make start
(uses uv
) or run npx @modelcontextprotocol/inspector uv run src/mcp_observer_server/server.py
.subscribe
tool to monitor a directory or file, (alternatively, you can run "List Resources", click a resource, and then click "Subscribe" button to subscribe to it).watched.txt
in src/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 the subscribe_default
tool.watched.txt
file (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.🎉
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:
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:
The server implementation features a streamlined architecture that prioritizes simplicity, reliability, and maintainability.
Simplified Structure
Efficient State Management
watched
dictionary for direct path-to-session mappingMCP Protocol Integration
Event Processing
call_soon_threadsafe
Notification System
Data Structure
watched
maps Path objects to sets of ServerSession objectsTool API
subscribe
and unsubscribe
Resource Handling
Event Processing
Notification Delivery
The implementation achieves a good balance between functionality and simplicity, resulting in a reliable and maintainable codebase.