On this page
MCP resources for PixelWeaver.
#server.src.pixelweaver.mcp_resources
#server.src.pixelweaver.mcp_resources
MCP resources for PixelWeaver.
Exposes project state as MCP resources so that LLM clients can read and subscribe to state changes. Resources are registered on the FastMCP mcp instance; subscriptions are wired through the low-level server so that mutating tool calls can push resource/updated notifications.
Resource URIs -------------
project://state-- full project overviewproject://canvas/{name}-- single canvas metadataproject://canvas/{name}/frame/{index}-- composited frame as PNGproject://palette-- colours in use on canvas
#get_subscribed_uris
def get_subscribed_uris() -> frozenset[str]Return a snapshot of currently subscribed URIs (for testing).
#_synced_state
async def _synced_state()Pull latest state and return it, or raise on failure.
#init_mcp_resources
def init_mcp_resources(mcp: FastMCP) -> NoneRegister all MCP resources on the FastMCP server instance.
Called from mcp_server.init_mcp_tools so resources and tools are initialised together.
#init_mcp_subscriptions
def init_mcp_subscriptions(mcp: FastMCP) -> NoneWire subscribe/unsubscribe handlers and enable the capability.
Must be called after init_mcp_resources but before the server starts accepting connections.
#notify_resource_subscribers
async def notify_resource_subscribers(mcp: FastMCP) -> NoneSend resource/updated for every currently-subscribed URI.
Called after a mutating tool pushes state back to the collab server, so the MCP client knows to re-read any resources it is watching.
This must run inside a request context (i.e. while a tool handler is executing) so we can access the session.