Skip to main content
Glama

apply_tree_layout

Apply a tree layout to visualize hierarchical network data in Graphistry, organizing nodes in layered structures for clearer analysis.

Instructions

Apply a tree (layered hierarchical) layout to the graph using Graphistry's tree_layout API.

Args:
    graph_id (str): The ID of the graph to modify.

Returns:
    dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.

Example:
    apply_tree_layout(graph_id)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes

Implementation Reference

  • The main handler function for the 'apply_tree_layout' tool. It is registered via the @mcp.tool() decorator. Retrieves the graph from cache, applies Graphistry's tree_layout(), updates the cache, and returns the graph ID and updated visualization URL.
    @mcp.tool()
    async def apply_tree_layout(graph_id: str) -> Dict[str, Any]:
        """
        Apply a tree (layered hierarchical) layout to the graph using Graphistry's tree_layout API.
    
        Args:
            graph_id (str): The ID of the graph to modify.
    
        Returns:
            dict: { 'graph_id': ..., 'url': ... } with the updated visualization URL.
    
        Example:
            apply_tree_layout(graph_id)
        """
        if graph_id not in graph_cache:
            raise ValueError(f"Graph not found: {graph_id}")
        g = graph_cache[graph_id]["graph"]
        g = g.tree_layout()
        graph_cache[graph_id]["graph"] = g
        return {"graph_id": graph_id, "url": g.plot(render=False)}
Behavior2/5

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

With no annotations, the description carries full burden but only states it modifies the graph and returns a URL. It doesn't disclose behavioral traits like whether this is a destructive operation, requires specific permissions, has rate limits, or how it handles errors. The mention of 'modify' hints at mutation but lacks details.

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

Conciseness4/5

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

The description is front-loaded with the core purpose, followed by structured Args and Returns sections, and an Example. It's appropriately sized with no redundant information, though the example could be more informative (e.g., showing a sample graph_id).

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

Completeness2/5

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

Given 1 parameter with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It covers the basic operation and return structure but lacks details on graph modification effects, error handling, or when to choose this over other layouts, making it insufficient for a mutation tool.

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

Parameters3/5

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

Schema description coverage is 0%, but the description adds minimal semantics: it names the parameter (graph_id) and states it's 'The ID of the graph to modify.' This provides basic meaning beyond the schema's type and title, but doesn't elaborate on format, constraints, or examples beyond the example call.

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 action ('Apply a tree layout') and resource ('to the graph'), specifying it uses Graphistry's tree_layout API. It distinguishes from siblings like 'apply_ring_categorical_layout' by mentioning 'tree (layered hierarchical)', but doesn't explicitly contrast with all layout alternatives.

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?

No guidance on when to use this tool versus other layout tools (e.g., apply_ring_categorical_layout, apply_modularity_weighted_layout) is provided. The description implies it's for hierarchical graphs but doesn't specify prerequisites or exclusions, leaving usage context unclear.

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/graphistry/graphistry-mcp'

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