subscribe
Track and receive real-time notifications for changes to files or directories, enabling AI assistants to respond automatically without manual updates via the MCP Observer Server.
Instructions
Subscribe to changes on a file or directory
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- The core handler logic for the 'subscribe' tool. It resolves the provided path, adds the current server session to the set of subscribers for that path in the global 'watched' dictionary, triggers a resource list changed notification if it's a new path, and returns a confirmation message.if name == "subscribe": assert path_str is not None, "path_str should not be None for subscribe tool" p = Path(path_str).expanduser().resolve() is_new_path = p not in watched watched.setdefault(p, set()).add(session) # Send notification if this is a new path being watched if is_new_path: asyncio.create_task(send_resources_list_changed_notification()) return [TextContent(type="text", text=f"Subscribed to {p}")]
- src/mcp_observer_server/server.py:62-70 (registration)Registration of the 'subscribe' tool in the list_tools() function, including name, description, and input schema requiring a 'path' string.Tool( name="subscribe", description="Subscribe to changes on a file or directory", inputSchema={ "type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"], }, ),
- Input schema for the 'subscribe' tool: an object with a required 'path' property of type string.inputSchema={ "type": "object", "properties": {"path": {"type": "string"}}, "required": ["path"], },