Skip to main content
Glama

list_nodes

Retrieve MRML node information from 3D Slicer by listing names, IDs, or properties with optional filtering by class, name, or ID.

Instructions

List MRML nodes via the Slicer Web Server API.

The filter_type parameter specifies the type of node information to retrieve. Possible values include "names" (node names), "ids" (node IDs), and "properties" (node properties). The default value is "names".

The class_name, name, and id parameters are optional and can be used to further filter nodes. The class_name parameter allows filtering nodes by class name. The name parameter allows filtering nodes by name. The id parameter allows filtering nodes by ID.

Examples:

  • List the names of all nodes: {"tool": "list_nodes", "arguments": {"filter_type": "names"}}

  • List the IDs of nodes of a specific class: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "class_name": "vtkMRMLModelNode"}}

  • List the properties of nodes with a specific name: {"tool": "list_nodes", "arguments": {"filter_type": "properties", "name": "MyModel"}}

  • List nodes with a specific ID: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "id": "vtkMRMLModelNode123"}}

Returns a dictionary containing node information. If filter_type is "names" or "ids", the returned dictionary contains a "nodes" key, whose value is a list containing node names or IDs. Example: {"nodes": ["node1", "node2", ...]} or {"nodes": ["id1", "id2", ...]} If filter_type is "properties", the returned dictionary contains a "nodes" key, whose value is a dictionary containing node properties. Example: {"nodes": {"node1": {"property1": "value1", "property2": "value2"}, ...}} If an error occurs, a dictionary containing an "error" key is returned, whose value is a string describing the error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filter_typeNonames
class_nameNo
nameNo
idNo

Implementation Reference

  • The complete implementation of the 'list_nodes' tool. This includes the @mcp.tool() decorator for registration, function signature and docstring providing schema (parameters, examples, return types), and the full handler logic that constructs API requests to the Slicer Web Server to retrieve node names, IDs, or properties based on filters.
    @mcp.tool() def list_nodes(filter_type: str = "names", class_name: str = None, name: str = None, id: str = None) -> dict: """ List MRML nodes via the Slicer Web Server API. The filter_type parameter specifies the type of node information to retrieve. Possible values include "names" (node names), "ids" (node IDs), and "properties" (node properties). The default value is "names". The class_name, name, and id parameters are optional and can be used to further filter nodes. The class_name parameter allows filtering nodes by class name. The name parameter allows filtering nodes by name. The id parameter allows filtering nodes by ID. Examples: - List the names of all nodes: {"tool": "list_nodes", "arguments": {"filter_type": "names"}} - List the IDs of nodes of a specific class: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "class_name": "vtkMRMLModelNode"}} - List the properties of nodes with a specific name: {"tool": "list_nodes", "arguments": {"filter_type": "properties", "name": "MyModel"}} - List nodes with a specific ID: {"tool": "list_nodes", "arguments": {"filter_type": "ids", "id": "vtkMRMLModelNode123"}} Returns a dictionary containing node information. If filter_type is "names" or "ids", the returned dictionary contains a "nodes" key, whose value is a list containing node names or IDs. Example: {"nodes": ["node1", "node2", ...]} or {"nodes": ["id1", "id2", ...]} If filter_type is "properties", the returned dictionary contains a "nodes" key, whose value is a dictionary containing node properties. Example: {"nodes": {"node1": {"property1": "value1", "property2": "value2"}, ...}} If an error occurs, a dictionary containing an "error" key is returned, whose value is a string describing the error. """ try: # Build API endpoint based on filter type endpoint_map = { "names": "/mrml/names", "ids": "/mrml/ids", "properties": "/mrml/properties" } if filter_type not in endpoint_map: return {"error": "Invalid filter_type specified"} api_url = f"{SLICER_WEB_SERVER_URL}{endpoint_map[filter_type]}" # Build query parameters params = {} if class_name: params["class"] = class_name if name: params["name"] = name if id: params["id"] = id # Send GET request to Slicer Web Server # Smart proxy handling: disable for localhost, use system default for others response = requests.get(api_url, params=params, proxies=get_proxy_config(api_url)) response.raise_for_status() # Process response based on filter type if filter_type == "properties": return {"nodes": response.json()} return {"nodes": response.json()} except requests.exceptions.HTTPError as e: return {"error": f"HTTP Error {e.response.status_code}: {str(e)}"} except json.JSONDecodeError: return {"error": f"Invalid JSON response: {response.text}"} except requests.exceptions.RequestException as e: return {"error": f"Connection error: {str(e)}"} except Exception as e: return {"error": f"Node listing failed: {str(e)}"}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zhaoyouj/mcp-slicer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server