Skip to main content
Glama

list_nodes

Retrieve MRML node details from the Slicer Web Server API. Filter by node names, IDs, properties, class name, or specific ID to extract targeted information. Returns structured data for efficient medical image processing and scene analysis.

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
class_nameNo
filter_typeNonames
idNo
nameNo

Implementation Reference

  • The list_nodes tool handler, decorated with @mcp.tool() for automatic registration with the FastMCP server. It implements the core logic to list MRML nodes by querying the Slicer Web Server API based on filter_type ('names', 'ids', 'properties') and optional filters (class_name, name, id). Includes input/output schema in type hints and comprehensive docstring.
    @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)}"}
  • Type hints and docstring define the input schema (filter_type:str='names', class_name:str=None, name:str=None, id:str=None) and output schema (dict with 'nodes' list/dict or 'error' str), including usage examples.
    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. """
  • The @mcp.tool() decorator registers the list_nodes function as an MCP tool with the FastMCP server instance.
    @mcp.tool()

Other Tools

Related Tools

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