Session & Viewer Controls¶
Functions for managing the napari viewer lifecycle, GUI state, and session information.
detect_viewers¶
MCP Tool Interface¶
Detect available viewers (local and external).
Returns:
Type | Description |
---|---|
dict
|
Dictionary with information about available viewers |
Source code in src/napari_mcp/server.py
Implementation¶
Detect available viewers (local and external).
Returns:
Type | Description |
---|---|
dict
|
Dictionary with information about available viewers |
Source code in src/napari_mcp/server.py
init_viewer¶
MCP Tool Interface¶
Create or return the napari viewer (local or external).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Optional window title (only for local viewer). |
None
|
width
|
int
|
Optional initial canvas width (only for local viewer). |
None
|
height
|
int
|
Optional initial canvas height (only for local viewer). |
None
|
port
|
int
|
If provided, attempt to connect to an external napari-mcp bridge on this port (default is taken from NAPARI_MCP_BRIDGE_PORT or 9999). |
None
|
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing status, viewer type, and layer info. |
Source code in src/napari_mcp/server.py
Implementation¶
Create or return the napari viewer (local or external).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
Optional window title (only for local viewer). |
None
|
width
|
int
|
Optional initial canvas width (only for local viewer). |
None
|
height
|
int
|
Optional initial canvas height (only for local viewer). |
None
|
port
|
int
|
If provided, attempt to connect to an external napari-mcp bridge on this port (default is taken from NAPARI_MCP_BRIDGE_PORT or 9999). |
None
|
Returns:
Type | Description |
---|---|
dict
|
Dictionary containing status, viewer type, and layer info. |
Source code in src/napari_mcp/server.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
close_viewer¶
MCP Tool Interface¶
Close the viewer window and clear all layers.
Returns:
Type | Description |
---|---|
dict
|
Dictionary with status: 'closed' if viewer existed, 'no_viewer' if none. |
Source code in src/napari_mcp/server.py
Implementation¶
Close the viewer window and clear all layers.
Returns:
Type | Description |
---|---|
dict
|
Dictionary with status: 'closed' if viewer existed, 'no_viewer' if none. |
Source code in src/napari_mcp/server.py
session_information¶
MCP Tool Interface¶
Get comprehensive information about the current napari session.
Returns:
Type | Description |
---|---|
dict
|
Comprehensive session information including viewer state, system info, and environment details. |
Source code in src/napari_mcp/server.py
Implementation¶
Get comprehensive information about the current napari session.
Returns:
Type | Description |
---|---|
dict
|
Comprehensive session information including viewer state, system info, and environment details. |
Source code in src/napari_mcp/server.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
|