Skip to main content
Glama

filter_cells

Filter single-cell RNA sequencing data by setting thresholds for gene expression counts and number of genes expressed to identify high-quality cells for analysis.

Instructions

Filter cells based on counts and numbers of genes expressed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
min_countsNoMinimum number of counts required for a cell to pass filtering.
min_genesNoMinimum number of genes expressed required for a cell to pass filtering.
max_countsNoMaximum number of counts required for a cell to pass filtering.
max_genesNoMaximum number of genes expressed required for a cell to pass filtering.

Implementation Reference

  • Generic handler function for all preprocessing tools, including filter_cells. Retrieves the scanpy function from pp_func, prepares arguments with inplace=True, executes on active adata, handles exceptions, and logs the operation.
    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 model defining the input parameters and validation for the filter_cells tool.
    class FilterCells(JSONParsingModel):
        """Input schema for the filter_cells preprocessing tool."""
        
        min_counts: Optional[int] = Field(
            default=None,
            description="Minimum number of counts required for a cell to pass filtering."
        )
        
        min_genes: Optional[int] = Field(
            default=None,
            description="Minimum number of genes expressed required for a cell to pass filtering."
        )
        
        max_counts: Optional[int] = Field(
            default=None,
            description="Maximum number of counts required for a cell to pass filtering."
        )
        
        max_genes: Optional[int] = Field(
            default=None,
            description="Maximum number of genes expressed required for a cell to pass filtering."
        )
        
        @field_validator('min_counts', 'min_genes', 'max_counts', 'max_genes')
        def validate_positive_integers(cls, v: Optional[int]) -> Optional[int]:
            """验证整数参数为正数"""
            if v is not None and v <= 0:
                raise ValueError("过滤参数必须是正整数")
            return v
  • Creates the MCP types.Tool instance for filter_cells, specifying name, description, and input schema.
    filter_cells = types.Tool(
        name="filter_cells",
        description="Filter cells based on counts and numbers of genes expressed.",
        inputSchema=FilterCells.model_json_schema(),
    )
  • Registers the filter_cells Tool object in the pp_tools dictionary, which is exposed via server.list_tools().
    "filter_cells": filter_cells,
  • Maps the 'filter_cells' tool name to scanpy's sc.pp.filter_cells function used by the handler.
    "filter_cells": sc.pp.filter_cells,
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. It states the filtering action but lacks details on behavioral traits: it does not specify if this is a destructive operation (e.g., removes cells from a dataset), what the output format is (e.g., returns filtered data or modifies in-place), or any performance considerations (e.g., handling of large datasets). This leaves significant gaps for an agent to understand the tool's behavior.

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 sentence: 'Filter cells based on counts and numbers of genes expressed.' It is front-loaded with the core purpose, has zero wasted words, and is appropriately sized for the tool's complexity. Every part of the sentence contributes essential information.

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 (a filtering tool with 4 parameters), lack of annotations, and no output schema, the description is incomplete. It does not explain what the tool returns (e.g., a filtered dataset, success status, or error messages), nor does it cover behavioral aspects like side effects or data handling. For a tool that likely modifies or subsets data, this leaves critical context gaps for an agent.

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?

The input schema has 100% description coverage, with clear documentation for all four parameters (min_counts, min_genes, max_counts, max_genes). The description adds no additional parameter semantics beyond what the schema provides, such as typical value ranges or interactions between parameters. Since schema coverage is high, the baseline score is 3, reflecting adequate but not enhanced parameter understanding.

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: 'Filter cells based on counts and numbers of genes expressed.' It specifies the verb ('filter') and resource ('cells'), and the criteria ('counts and numbers of genes expressed'). However, it does not explicitly differentiate from sibling tools like 'filter_genes' or 'filter_rank_genes_groups', which reduces the score from 5 to 4.

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. It does not mention sibling tools like 'filter_genes' (which filters genes, not cells) or 'calculate_qc_metrics' (which might compute metrics for filtering). There are no explicit when/when-not statements or prerequisites, leaving usage 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/huang-sh/scmcp'

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