Skip to main content
Glama

diffmap

Apply diffusion maps to reduce dimensionality in single-cell RNA sequencing data, enabling visualization and analysis of high-dimensional biological datasets.

Instructions

Diffusion Maps for dimensionality reduction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
n_compsNoThe number of dimensions of the representation.
neighbors_keyNoIf not specified, diffmap looks .uns['neighbors'] for neighbors settings and .obsp['connectivities'], .obsp['distances'] for connectivities and distances respectively. If specified, diffmap looks .uns[neighbors_key] for neighbors settings and uses the corresponding connectivities and distances.
random_stateNoRandom seed for reproducibility.

Implementation Reference

  • Handler function that executes the tool logic for 'diffmap' by dispatching to sc.tl.diffmap with input arguments, adds operation log, and handles errors.
    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 
  • Pydantic model defining the input schema and validation rules for the 'diffmap' tool.
    class DiffMapModel(JSONParsingModel):
        """Input schema for the Diffusion Maps dimensionality reduction tool."""
        
        n_comps: int = Field(
            default=15,
            description="The number of dimensions of the representation.",
            gt=0
        )
        neighbors_key: Optional[str] = Field(
            default=None,
            description=(
                "If not specified, diffmap looks .uns['neighbors'] for neighbors settings "
                "and .obsp['connectivities'], .obsp['distances'] for connectivities and "
                "distances respectively. If specified, diffmap looks .uns[neighbors_key] for "
                "neighbors settings and uses the corresponding connectivities and distances."
            )
        )
        random_state: int = Field(
            default=0,
            description="Random seed for reproducibility."
        )
        
        @field_validator('n_comps')
        def validate_positive_integers(cls, v: int) -> int:
            """Validate positive integers"""
            if v <= 0:
                raise ValueError("n_comps must be a positive integer")
            return v
  • Registration of the 'diffmap' tool as an MCP Tool object with name, description, and reference to the input schema.
    # Add diffmap tool
    diffmap_tool = types.Tool(
        name="diffmap",
        description="Diffusion Maps for dimensionality reduction",
        inputSchema=DiffMapModel.model_json_schema(),
    )
  • Mapping from tool name 'diffmap' to the underlying scanpy function sc.tl.diffmap used by the handler.
    tl_func = {
        "tsne": sc.tl.tsne,
        "umap": sc.tl.umap,
        "draw_graph": sc.tl.draw_graph,
        "diffmap": sc.tl.diffmap,
        "embedding_density": sc.tl.embedding_density,
        "leiden": sc.tl.leiden,
        "louvain": sc.tl.louvain,
        "dendrogram": sc.tl.dendrogram,
        "dpt": sc.tl.dpt,
        "paga": sc.tl.paga,
        "ingest": sc.tl.ingest,
        "rank_genes_groups": sc.tl.rank_genes_groups,
        "filter_rank_genes_groups": sc.tl.filter_rank_genes_groups,
        "marker_gene_overlap": sc.tl.marker_gene_overlap,
        "score_genes": sc.tl.score_genes,
        "score_genes_cell_cycle": sc.tl.score_genes_cell_cycle,
    }
  • MCP server list_tools method that includes tl_tools.values(), thereby registering the 'diffmap' tool when MODULE includes 'tl'.
    @server.list_tools()
    async def list_tools() -> list[types.Tool]:
        if MODULE == "io":
            tools = io_tools.values()
        elif MODULE == "pp":
            tools = pp_tools.values()
        elif MODULE == "tl":
            tools = tl_tools.values()
        elif MODULE == "pl":
            tools = pl_tools.values()
        elif MODULE == "util":
            tools = util_tools.values()
        else:
            tools = [
                *io_tools.values(),
                *pp_tools.values(),
                *tl_tools.values(),
                *pl_tools.values(),
                *util_tools.values(),
                *ccc_tools.values(),
            ]
        return tools
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides minimal information. It doesn't mention whether this is a read-only or destructive operation, what permissions might be needed, computational complexity, memory requirements, or what the output looks like. The description only states what the tool does, not how it behaves.

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 extremely concise at just 4 words, with zero wasted language. It's front-loaded with the core purpose and contains no unnecessary elaboration. This is an example of efficient communication where every word earns its place.

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 this is a dimensionality reduction tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what diffusion maps are, what they're particularly good for, what the output format will be, or how results should be interpreted. For a complex statistical method, more contextual information would be helpful.

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?

With 100% schema description coverage, the baseline is 3. The description adds no parameter information beyond what's already documented in the schema. All three parameters (n_comps, neighbors_key, random_state) are fully described in the input schema with clear explanations and defaults.

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 as performing 'Diffusion Maps for dimensionality reduction', which is a specific verb+resource combination. However, it doesn't differentiate this from sibling tools like pca, tsne, or umap that also perform dimensionality reduction, which prevents a perfect score.

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 multiple dimensionality reduction methods available (pca, tsne, umap, etc.), the description offers no context about when diffusion maps are preferable, what data characteristics they work best with, or any prerequisites for use.

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