Skip to main content
Glama

apply_modularity_weighted_layout

Optimize graph visualization by applying modularity-based weighted layout to reveal community structures and relationships in network data.

Instructions

Apply modularity weighted layout to the graph using Graphistry's modularity_weighted_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_modularity_weighted_layout(graph_id)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graph_idYes

Implementation Reference

  • The @mcp.tool()-decorated handler function that applies Graphistry's modularity_weighted_layout to the specified graph from cache and returns the updated visualization URL. This is both the implementation and registration of the tool.
    async def apply_modularity_weighted_layout(graph_id: str) -> Dict[str, Any]:
        """
        Apply modularity weighted layout to the graph using Graphistry's modularity_weighted_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_modularity_weighted_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.modularity_weighted_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?

No annotations are provided, so the description carries the full burden. It states the tool modifies the graph and returns a URL, implying a mutation with visual output, but lacks details on permissions, side effects, rate limits, or whether the layout is destructive to existing graph data. This is a significant gap for a mutation tool.

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

Conciseness5/5

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

The description is well-structured and front-loaded with the core purpose, followed by Args, Returns, and Example sections. Every sentence adds value without redundancy, making it efficient and easy to scan.

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

Completeness3/5

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

Given no annotations, no output schema, and low schema coverage, the description is incomplete. It covers the basic operation and return format but misses behavioral context like mutation risks or usage guidelines. For a layout tool among many siblings, more guidance would be beneficial.

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 basic semantics by explaining 'graph_id' as 'The ID of the graph to modify.' However, it doesn't elaborate on format, constraints, or examples beyond the schema's title. With one parameter, the baseline is 4, but the minimal added value reduces it to 3.

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 modularity weighted layout') and resource ('to the graph'), specifying it uses Graphistry's API. It distinguishes from siblings by mentioning 'modularity_weighted_layout' but doesn't explicitly contrast with other layout tools like 'apply_tree_layout' or 'apply_ring_categorical_layout'.

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 is provided on when to use this tool versus alternatives. The description mentions the API but doesn't explain scenarios for choosing modularity weighted layout over other layout tools in the sibling list, such as for community detection or weighted networks.

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