Skip to main content
Glama

scale

Standardize single-cell RNA sequencing data by scaling to unit variance and zero mean for preprocessing and analysis.

Instructions

Scale data to unit variance and zero mean

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
zero_centerNoIf False, omit zero-centering variables to handle sparse input efficiently.
max_valueNoClip (truncate) to this value after scaling. If None, do not clip.
layerNoIf provided, which element of layers to scale.
obsmNoIf provided, which element of obsm to scale.
mask_obsNoBoolean mask or string referring to obs column for subsetting observations.

Implementation Reference

  • Generic handler that executes sc.pp.scale (via pp_func['scale']) on the active AnnData object for the 'scale' tool.
    def run_pp_func(ads, func, arguments):
        adata = ads.adata_dic[ads.active]
        if func not in pp_func:
            raise ValueError(f"不支持的函数: {func}")
        
        run_func = pp_func[func]
        parameters = inspect.signature(run_func).parameters
        arguments["inplace"] = True
        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 KeyError as e:
            raise KeyError(f"Can not foud {e} column in adata.obs or adata.var")
        except Exception as e:
           raise e
        return res
  • Pydantic input schema model for the 'scale' tool, defining parameters and validation.
    class ScaleModel(JSONParsingModel):
        """Input schema for the scale preprocessing tool."""
        
        zero_center: bool = Field(
            default=True,
            description="If False, omit zero-centering variables to handle sparse input efficiently."
        )
        
        max_value: Optional[float] = Field(
            default=None,
            description="Clip (truncate) to this value after scaling. If None, do not clip."
        )
        
        layer: Optional[str] = Field(
            default=None,
            description="If provided, which element of layers to scale."
        )
        
        obsm: Optional[str] = Field(
            default=None,
            description="If provided, which element of obsm to scale."
        )
        
        mask_obs: Optional[Union[str, bool]] = Field(
            default=None,
            description="Boolean mask or string referring to obs column for subsetting observations."
        )
        
        @field_validator('max_value')
        def validate_max_value(cls, v: Optional[float]) -> Optional[float]:
            """Validate max_value is positive if provided"""
            if v is not None and v <= 0:
                raise ValueError("max_value must be positive if provided")
            return v
  • MCP tool registration defining the 'scale' tool name, description, and input schema.
    scale = types.Tool(
        name="scale",
        description="Scale data to unit variance and zero mean",
        inputSchema=ScaleModel.model_json_schema(),
    )
  • Dictionary mapping tool names to Scanpy functions, with 'scale' mapped to sc.pp.scale used by the handler.
    pp_func = {
        "filter_genes": sc.pp.filter_genes,
        "filter_cells": sc.pp.filter_cells,
        "calculate_qc_metrics": partial(sc.pp.calculate_qc_metrics, inplace=True),
        "log1p": sc.pp.log1p,
        "normalize_total": sc.pp.normalize_total,
        "pca": sc.pp.pca,
        "highly_variable_genes": sc.pp.highly_variable_genes,
        "regress_out": sc.pp.regress_out,
        "scale": sc.pp.scale,
        "combat": sc.pp.combat,
        "scrublet": sc.pp.scrublet,
        "neighbors": sc.pp.neighbors,
    }
  • Dictionary of registered MCP tools, including the 'scale' tool instance.
    pp_tools = {
        "filter_genes": filter_genes,
        "filter_cells": filter_cells,
        "calculate_qc_metrics": calculate_qc_metrics,
        "log1p": log1p,
        "normalize_total": normalize_total,
        "pca": pca,
        "highly_variable_genes": highly_variable_genes,
        "regress_out": regress_out,
        "scale": scale,
        "combat": combat,
        "scrublet": scrublet,
        "neighbors": neighbors,
    }
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 of behavioral disclosure. While 'scale' implies a transformation operation, the description doesn't mention whether this modifies data in-place, creates a new dataset, what permissions are required, error conditions, or performance characteristics. For a data transformation tool with zero annotation coverage, this is insufficient.

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, clear sentence with zero waste. It's appropriately sized and front-loaded with the essential information about what the tool does.

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 data transformation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what gets returned (transformed data object? success indicator?), what format the output takes, or how this integrates with the broader data processing workflow alongside sibling tools.

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 5 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. This meets the baseline of 3 when the schema does the heavy lifting, but no extra value is provided.

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: 'Scale data to unit variance and zero mean' - this specifies the verb ('scale') and the transformation outcome. However, it doesn't differentiate from potential sibling tools that might also transform data (like normalize_total or log1p), so it doesn't reach the highest 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 many sibling tools for data transformation and preprocessing (normalize_total, log1p, regress_out, etc.), there's no indication of when scaling is appropriate versus other normalization methods or when to combine them.

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