list_layers
Retrieve a list of all SketchUp model layers including name, visibility, color, and ID for layer management.
Instructions
List all model layers as {name, visible, color, id}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/sketchup_mcp/tools.py:432-435 (handler)Main tool handler for 'list_layers'. Decorated with @mcp.tool(), it calls _call(ctx, 'list_layers') to dispatch the command to SketchUp.
@mcp.tool() async def list_layers(ctx: Context) -> str: """List all model layers as {name, visible, color, id}.""" return await _call(ctx, "list_layers") - src/sketchup_mcp/tools.py:432-435 (registration)The @mcp.tool() decorator on the list_layers function registers it as a FastMCP tool. This import is triggered side-effectfully from app.py.
@mcp.tool() async def list_layers(ctx: Context) -> str: """List all model layers as {name, visible, color, id}.""" return await _call(ctx, "list_layers") - src/sketchup_mcp/tools.py:48-75 (helper)The _call helper function dispatches the tool_name ('list_layers') to SketchUp via _raw_call -> send_command, handling errors and response unwrapping.
async def _call(ctx: Context, tool_name: str, /, **kwargs) -> str: """Dispatch a tool call to SketchUp and shape the response for Claude. Same external contract as before — kept for compatibility with the 22 existing string-returning tools. Now delegates to :func:`_raw_call` for connection acquisition and converts the result to a string. Connection failures surface as the canonical legacy string so the LLM sees a stable, actionable hint. """ try: result = await _raw_call(ctx, tool_name, **kwargs) except ConnectionError as e: return f"SketchUp not running or extension not started: {e}" except SketchUpError as e: return format_error(e, debug=config.LOG_LEVEL == "DEBUG") content = result.get("content") if isinstance(result, dict) else None if ( isinstance(content, list) and content and isinstance(content[0], dict) and "text" in content[0] ): return content[0]["text"] return json.dumps(result) @mcp.tool() async def create_component( - src/sketchup_mcp/connection.py:43-55 (helper)list_layers is listed in _RETRY_SAFE_TOOLS (frozenset), meaning it's considered read-only/side-effect-free and safe to retry if the socket becomes stale.
_RETRY_SAFE_TOOLS: frozenset[str] = frozenset( { "get_model_info", "list_components", "get_component_info", "find_components", "list_layers", "get_selection", "get_viewport_screenshot", # read-only viewport capture; idempotent in # both restore_view modes (no document state changes) "get_version", # read-only diagnostic; no side effects } ) - src/sketchup_mcp/tools.py:433-434 (schema)Docstring serves as the schema/description: 'List all model layers as {name, visible, color, id}.'. No input parameters.
async def list_layers(ctx: Context) -> str: """List all model layers as {name, visible, color, id}."""