Skip to main content
Glama

draw_graph

Visualize single-cell RNA sequencing data using force-directed graph layouts to reveal relationships and patterns in biological datasets.

Instructions

Force-directed graph drawing for visualization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
layoutNoGraph layout algorithm ('fa', 'fr', 'kk', etc.)fa
init_posNoInitial position for nodes ('paga'/True, False, or .obsm key)
rootNoRoot node for tree layouts
random_stateNoRandom seed for reproducibility
n_jobsNoNumber of jobs for parallel computation
key_added_extNoSuffix for storing results in .obsm
neighbors_keyNoKey for neighbors settings in .uns
obspNoKey for adjacency matrix in .obsp

Implementation Reference

  • Pydantic model defining the input schema for the draw_graph tool, including parameters like layout, init_pos, root, etc., with validation.
    class DrawGraphModel(JSONParsingModel):
        """Input schema for the force-directed graph drawing tool."""
        
        layout: str = Field(
            default='fa',
            description="Graph layout algorithm ('fa', 'fr', 'kk', etc.)",
        )
        init_pos: Optional[Union[str, bool]] = Field(
            default=None,
            description="Initial position for nodes ('paga'/True, False, or .obsm key)",
        )
        root: Optional[int] = Field(
            default=None,
            description="Root node for tree layouts",
            ge=0
        )
        random_state: int = Field(
            default=0,
            description="Random seed for reproducibility"
        )
        n_jobs: Optional[int] = Field(
            default=None,
            description="Number of jobs for parallel computation",
            gt=0
        )
        key_added_ext: Optional[str] = Field(
            default=None,
            description="Suffix for storing results in .obsm"
        )
        neighbors_key: Optional[str] = Field(
            default=None,
            description="Key for neighbors settings in .uns"
        )
        obsp: Optional[str] = Field(
            default=None,
            description="Key for adjacency matrix in .obsp"
        )
        
        @field_validator('layout')
        def validate_layout(cls, v: str) -> str:
            """Validate layout is supported"""
            valid_layouts = ['fa', 'fr', 'grid_fr', 'kk', 'lgl', 'drl', 'rt']
            if v.lower() not in valid_layouts:
                raise ValueError(f"layout must be one of {valid_layouts}")
            return v.lower()
        
        @field_validator('root', 'n_jobs')
        def validate_positive_integers(cls, v: Optional[int]) -> Optional[int]:
            """Validate positive integers where applicable"""
            if v is not None and v <= 0:
                raise ValueError("must be a positive integer")
            return v
  • Definition of the draw_graph Tool object with name, description, and input schema reference.
    # Add draw_graph tool
    draw_graph_tool = types.Tool(
        name="draw_graph",
        description="Force-directed graph drawing for visualization",
        inputSchema=DrawGraphModel.model_json_schema(),
    )
  • tl_tools dictionary registers the draw_graph_tool along with other tl tools for use in server.list_tools().
    tl_tools = {
        "tsne": tsne_tool,
        "umap": umap_tool,
        "draw_graph": draw_graph_tool,
        "diffmap": diffmap_tool,
        "embedding_density": embedding_density_tool,
        "leiden": leiden_tool,
        "louvain": louvain_tool,
        "dendrogram": dendrogram_tool,
        "dpt": dpt_tool,
        "paga": paga_tool,
        "ingest": ingest_tool,
        "rank_genes_groups": rank_genes_groups_tool,
        "filter_rank_genes_groups": filter_rank_genes_groups_tool,
        "marker_gene_overlap": marker_gene_overlap_tool,
        "score_genes": score_genes_tool,
        "score_genes_cell_cycle": score_genes_cell_cycle_tool,
    }
  • MCP server call_tool handler dispatches draw_graph (in tl_tools) to run_tl_func.
    @server.call_tool()
    async def call_tool(
        name: str, arguments
    ):
        try:
            logger.info(f"Running {name} with {arguments}")
            if name in io_tools.keys():            
                res = run_io_func(ads, name, arguments)
            elif name in pp_tools.keys():
                res = run_pp_func(ads, name, arguments)
            elif name in tl_tools.keys():
                res = run_tl_func(ads, name, arguments) 
            elif name in pl_tools.keys():
                res = run_pl_func(ads, name, arguments)
            elif name in util_tools.keys():            
                res = run_util_func(ads, name, arguments)
            elif name in ccc_tools.keys():            
                res = run_ccc_func(ads.adata_dic[ads.active], name, arguments)
            output = str(res) if res is not None else str(ads.adata_dic[ads.active])
            return [
                types.TextContent(
                    type="text",
                    text=str({"output": output})
                )
            ]
        except Exception as error:
            logger.error(f"{name} with {error}")
            return [
                types.TextContent(
                    type="text",
                    text=str({"Error": error})
                )
            ]
  • Helper function that executes the tool by calling sc.tl.draw_graph(adata, **kwargs) for func='draw_graph'.
    def run_tl_func(ads, func, arguments):
        adata = ads.adata_dic[ads.active]
        if func not in tl_func:
            raise ValueError(f"Unsupported function: {func}")
        run_func = tl_func[func]
        parameters = inspect.signature(run_func).parameters
        kwargs = {k: arguments.get(k) for k in parameters if k in arguments}    
        try:
            res = run_func(adata, **kwargs)
            add_op_log(adata, run_func, kwargs)
        except Exception as e:
            logger.error(f"Error running function {func}: {e}")
            raise
        return 
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'force-directed graph drawing' which implies a computational process, but fails to describe what the tool actually does behaviorally: does it modify data structures, create visual output files, or update internal state? It doesn't address permissions, side effects, or output format, leaving significant gaps for a tool with 8 parameters.

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 a single, efficient phrase that's appropriately sized for its purpose. It's front-loaded with the core functionality and contains no wasted words. Every part of the description earns its place by conveying the essential concept without unnecessary elaboration.

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 the complexity (8 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain what the tool actually produces (e.g., a visualization file, updated data structure, or plot object), what data it operates on, or how it integrates with the broader workflow. For a visualization tool with many parameters, this leaves too many unanswered questions for effective use.

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 100%, so the schema already documents all 8 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description, which applies here.

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

Purpose3/5

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

The description 'Force-directed graph drawing for visualization' states the general purpose (graph drawing) and technique (force-directed), but it's vague about what specific resource it operates on and doesn't distinguish from sibling tools like 'paga', 'dendrogram', or 'embedding_density' which also create visualizations. It lacks the specificity needed for clear tool selection.

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. With many sibling tools for visualization (e.g., 'paga', 'dendrogram', 'pl_embedding'), there's no indication of what makes 'draw_graph' distinct or appropriate for certain scenarios over others. This leaves the agent guessing about proper tool selection.

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/huang-sh/scmcp'

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