PixelWeaver v0.5.0 /server.src.pixelweaver.mcp_resources
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 overview
  • project://canvas/{name} -- single canvas metadata
  • project://canvas/{name}/frame/{index} -- composited frame as PNG
  • project://palette -- colours in use on canvas

#get_subscribed_uris

python
def get_subscribed_uris() -> frozenset[str]

Return a snapshot of currently subscribed URIs (for testing).

#_synced_state

python
async def _synced_state()

Pull latest state and return it, or raise on failure.

#init_mcp_resources

python
def init_mcp_resources(mcp: FastMCP) -> None

Register 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

python
def init_mcp_subscriptions(mcp: FastMCP) -> None

Wire subscribe/unsubscribe handlers and enable the capability.

Must be called after init_mcp_resources but before the server starts accepting connections.

#notify_resource_subscribers

python
async def notify_resource_subscribers(mcp: FastMCP) -> None

Send 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.

Search