On this page
Layer tools for MCP registry.
#server.src.pixelweaver.mcp_layer_tools
#server.src.pixelweaver.mcp_layer_tools
Layer tools for MCP registry.
#register_layer_tools
def register_layer_tools(registry: MCPCommandRegistry) -> NoneRegister all layer-related MCP tools.
#_resolve_canvas_and_layer
def _resolve_canvas_and_layer(registry: MCPCommandRegistry, args: dict[str, Any], tool: str) -> tuple[Any, Any, dict[str, Any]] | dict[str, Any]Resolve (canvas, layer_dict) from args, or return a structured error.
The canvas is selected by canvas_name (unknown => error) else the first canvas; the layer is selected by layer_id (unknown => error).
#_register_layer_management
def _register_layer_management(registry: MCPCommandRegistry) -> NoneBespoke handlers for the layer-management tools.
These previously routed through the generic drawing-tool dispatcher, which -- because they are not drawing commands -- appended a command to history and returned success WITHOUT mutating canvas.layers. They now mutate the authoritative layer tree directly, then dispatch (history + broadcast) and push a full-state patch so every client repaints.
#_register_add_layer
def _register_add_layer(registry: MCPCommandRegistry) -> NoneBespoke add_layer handler that maintains canvas.layers (rgba + role).
Pulled OUT of the generic drawing-tool loop so MCP-created layers actually enter canvas.layers -- closing the gap where the shade validator and the layer-kind capability guard silently skipped MCP-created layers.