Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYes

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}")]
  • 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"], },

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hesreallyhim/mcp-observer-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server