Session & Viewer Controls¶
Functions for managing the napari viewer lifecycle, GUI state, and session information.
init_viewer¶
async def init_viewer(title: str | None = None, width: int | str | None = None, height: int | str | None = None, port: int | str | None = None, detect_only: bool = False) -> dict[str, Any]
Create or return the napari viewer, with viewer detection.
When detect_only=True, reports available viewers (local and
external) without creating or modifying anything.
Parameters¶
title : str, optional Optional window title (only for local viewer). width : int, optional Optional initial canvas width (only for local viewer). height : int, optional Optional initial canvas height (only for local viewer). port : int, optional If provided, attempt to connect to an external napari-mcp bridge on this port (default is taken from NAPARI_MCP_BRIDGE_PORT or 9999). detect_only : bool, default=False If True, only detect available viewers without initialising.
close_viewer¶
Close the viewer window and clear all layers.
session_information¶
Get comprehensive information about the current napari session.