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)}"}
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It effectively discloses behavioral traits: it describes the return format for different filter_type values, error handling, and default behavior. However, it lacks details on rate limits, authentication needs, or side effects, which would be beneficial for a read operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized but not optimally structured. It front-loads the purpose, but includes extensive parameter explanations and examples that could be more concise. Every sentence adds value, but some redundancy exists (e.g., repeating filter_type details).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description provides good completeness. It explains parameters, return values, and error handling. However, it lacks context on prerequisites (e.g., API setup) or performance considerations, which would enhance completeness for a tool with 4 parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It adds significant meaning beyond the schema: it explains filter_type values ('names', 'ids', 'properties'), default behavior, and how optional parameters (class_name, name, id) filter nodes. Examples further clarify usage, fully covering all 4 parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'List MRML nodes via the Slicer Web Server API.' It specifies the verb ('List') and resource ('MRML nodes'), but does not differentiate from sibling tools like 'capture_screenshot' or 'execute_python_code', which are unrelated. The purpose is specific but lacks sibling comparison.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It explains parameters and examples but does not mention any sibling tools or contexts where this tool is preferred. Usage is implied through examples, but explicit guidelines are missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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