Skip to main content
Glama

mark_var

Identify genes meeting specific conditions like mitochondrial, ribosomal, or hemoglobin patterns and store boolean results in adata.var for quality control analysis.

Instructions

Determine if each gene meets specific conditions and store results in adata.var as boolean values.for example: mitochondrion genes startswith MT-.the tool should be call first when calculate quality control metrics for mitochondrion, ribosomal, harhemoglobin genes. or other qc_vars

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
var_nameNoColumn name that will be added to adata.var, do not set if user does not ask
pattern_typeNoPattern matching type (startswith/endswith/contains), it should be None when gene_class is not None
patternsNogene pattern to match, must be a string, it should be None when gene_class is not None
gene_classNoGene class type (Mitochondrion/Ribosomal/Hemoglobin)

Implementation Reference

  • The handler function implementing the core logic of the 'mark_var' tool. It adds boolean columns to adata.var for specific gene classes (mt, ribo, hb) or based on custom patterns.
    def mark_var(adata, var_name: str = None, gene_class: str = None, 
                 pattern_type: str = None, patterns: str = None):
        if gene_class is not None:
            if gene_class == "mitochondrion":
                adata.var["mt"] = adata.var_names.str.startswith(('MT-', 'Mt','mt-'))
                var_name = "mt"
            elif gene_class == "ribosomal":
                adata.var["ribo"] = adata.var_names.str.startswith(("RPS", "RPL"))
                var_name = "ribo"
            elif gene_class == "hemoglobin":
                adata.var["hb"] = adata.var_names.str.contains("^HB[^(P)]", case=False)
                var_name = "hb"
        
        if pattern_type is not None and patterns is not None:
            if pattern_type == "startswith":
                adata.var[var_name] = adata.var_names.str.startswith(patterns)
            elif pattern_type == "endswith":
                adata.var[var_name] = adata.var_names.str.endswith(patterns)
            elif pattern_type == "contains":
                adata.var[var_name] = adata.var_names.str.contains(patterns)
            else:
                raise ValueError(f"Did not support pattern_type: {pattern_type}")
        return {var_name: adata.var[var_name].value_counts().to_dict(), "msg": f"add '{var_name}' column  in adata.var"}
  • Pydantic model (MarkVarModel) providing input schema validation for the mark_var tool parameters.
    class MarkVarModel(JSONParsingModel):
        """Determine or mark if each gene meets specific conditions and store results in adata.var as boolean values"""
        
        var_name: str = Field(
            default=None,
            description="Column name that will be added to adata.var, do not set if user does not ask"
        )
        pattern_type: Optional[Literal["startswith", "endswith", "contains"]] = Field(
            default=None,
            description="Pattern matching type (startswith/endswith/contains), it should be None when gene_class is not None"
        )    
        patterns: str = Field(
            default=None,
            description="gene pattern to match, must be a string, it should be None when gene_class is not None"
        )
        
        gene_class: Optional[Literal["mitochondrion", "ribosomal", "hemoglobin"]] = Field(
            default=None,
            description="Gene class type (Mitochondrion/Ribosomal/Hemoglobin)"
        )
  • MCP Tool object creation for 'mark_var', which is included in util_tools dict and exposed via server.list_tools().
    mark_var_tool = types.Tool(
        name="mark_var",
        description=(
            "Determine if each gene meets specific conditions and store results in adata.var as boolean values."
            "for example: mitochondrion genes startswith MT-."
            "the tool should be call first when calculate quality control metrics for mitochondrion, ribosomal, harhemoglobin genes. or other qc_vars"
        ),
        inputSchema=MarkVarModel.model_json_schema(),
    )
  • Server's list_tools handler that includes util_tools.values() (containing mark_var_tool) when MODULE=='util' or 'all'.
    @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
  • Server's call_tool handler that dispatches to run_util_func for tools in util_tools, invoking the mark_var handler.
    @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})
                )
            ]
Behavior3/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. It explains the tool creates boolean values in adata.var and provides an example (mitochondrion genes startswith MT-), which adds useful context. However, it doesn't mention important behavioral aspects like whether this operation modifies data in-place, what happens to existing columns, error conditions, or performance characteristics. The description adds some value but leaves significant gaps.

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

Conciseness3/5

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

The description is reasonably concise but has structural issues. The first sentence clearly states the purpose, but the second sentence has grammatical errors ('startswith' should be 'start with') and mixes example with usage guidance. The final clause 'or other qc_vars' is vague. While not excessively long, the structure could be cleaner with better separation of concepts.

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 4 parameters with 100% schema coverage but no annotations and no output schema, the description provides adequate context for the tool's purpose and primary use case. However, for a data mutation tool (adding columns to adata.var), the description should ideally mention more about the behavioral implications - whether this is reversible, what format the output takes, or how it interacts with other QC tools. The example helps but doesn't fully compensate for the lack of output schema.

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 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. It mentions 'mitochondrion genes startswith MT-' as an example, which relates to the pattern_type and patterns parameters, but doesn't provide additional syntax, format details, or usage patterns beyond the schema. Baseline 3 is appropriate when the schema does the heavy lifting.

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 states the tool's purpose clearly: 'Determine if each gene meets specific conditions and store results in adata.var as boolean values.' It specifies the verb (determine/mark), resource (genes), and output location (adata.var). However, it doesn't explicitly differentiate from sibling tools like 'filter_genes' or 'check_gene' that might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool: 'the tool should be called first when calculate quality control metrics for mitochondrion, ribosomal, hemoglobin genes. or other qc_vars.' This gives explicit guidance about the primary use case (QC preprocessing) and timing (first step). However, it doesn't mention when NOT to use it or explicitly name alternatives among the many sibling tools.

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