Skip to main content
Glama

pl_tracksplot

Create compact plots to visualize gene expression patterns across cell groups in single-cell RNA sequencing data, enabling biological insights without coding.

Instructions

tracksplot,compact plot of expression of a list of genes..

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
figsizeNoFigure size. Format is (width, height).
color_mapNoColor map to use for continuous variables.
paletteNoColors to use for plotting categorical annotation groups.
vmaxNoThe value representing the upper limit of the color scale.
vminNoThe value representing the lower limit of the color scale.
vcenterNoThe value representing the center of the color scale.
legend_fontsizeNoNumeric size in pt or string describing the size.
legend_fontweightNoLegend font weight. A numeric value in range 0-1000 or a string.bold
legend_locNoLocation of legend, either 'on data', 'right margin' or a valid keyword for the loc parameter.right margin
legend_fontoutlineNoLine width of the legend font outline in pt.
var_namesNovar_names should be a valid subset of adata.var_names or a mapping where the key is used as label to group the values.
groupbyYesThe key of the observation grouping to consider.
use_rawNoUse raw attribute of adata if present.
logNoPlot on logarithmic axis.
dendrogramNoIf True or a valid dendrogram key, a dendrogram based on the hierarchical clustering between the groupby categories is added.
gene_symbolsNoColumn name in .var DataFrame that stores gene symbols.
var_group_positionsNoUse this parameter to highlight groups of var_names with brackets or color blocks between the given start and end positions.
var_group_labelsNoLabels for each of the var_group_positions that want to be highlighted.
layerNoName of the AnnData object layer that wants to be plotted.

Implementation Reference

  • Generic handler function that executes Scanpy plotting tools, including 'pl_tracksplot'. It maps the tool name to sc.pl.tracksplot and calls it with validated arguments.
    def run_pl_func(ads, func, arguments):
        """
        Execute a Scanpy plotting function with the given arguments.
        
        Parameters
        ----------
        adata : AnnData
            Annotated data matrix.
        func : str
            Name of the plotting function to execute.
        arguments : dict
            Arguments to pass to the plotting function.
            
        Returns
        -------
        The result of the plotting function.
        """
        adata = ads.adata_dic[ads.active]
        if func not in pl_func:
            raise ValueError(f"Unsupported function: {func}")
    
        run_func = pl_func[func]
        parameters = inspect.signature(run_func).parameters
        kwargs = {k: arguments.get(k) for k in parameters if k in arguments}    
    
        if "title" not in parameters:
            kwargs.pop("title", False)    
        kwargs.pop("return_fig", True)
        kwargs["show"] = False
        kwargs["save"] = ".png"
        try:
            fig = run_func(adata, **kwargs)
            fig_path = set_fig_path(func, **kwargs)
            add_op_log(adata, run_func, kwargs)
            return fig_path 
        except Exception as e:
            raise e
        return fig_path
  • Pydantic model defining the input schema for the 'pl_tracksplot' tool. Inherits fields from BaseMatrixModel for var_names, groupby, etc.
    # 重构 TracksplotModel
    class TracksplotModel(BaseMatrixModel):
        """Input schema for the tracksplot plotting tool."""
        # 所有需要的字段已经在 BaseMatrixModel 中定义
  • MCP Tool object registration for 'pl_tracksplot', specifying name, description, and input schema.
    pl_tracksplot = types.Tool(
        name="pl_tracksplot",
        description="tracksplot,compact plot of expression of a list of genes..",
        inputSchema=TracksplotModel.model_json_schema(),
    )
  • Mapping of 'pl_tracksplot' tool name to the underlying Scanpy function sc.pl.tracksplot used in the handler.
    "pl_tracksplot": sc.pl.tracksplot,
  • Server registration of tools via list_tools(), including pl_tools.values() which contains the 'pl_tracksplot' tool.
    @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
  • Main MCP tool call handler that dispatches 'pl_tracksplot' (in pl_tools) to run_pl_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})
                )
            ]
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 only states what the tool does, not how it behaves. It lacks information on output format (e.g., image file, display), side effects, performance, or error handling, which is insufficient for a plotting tool with many parameters.

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

Conciseness4/5

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

The description is a single, efficient sentence with no wasted words. It's appropriately sized for a basic purpose statement, though it could be more informative given the tool's complexity.

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 tool's complexity (19 parameters, no output schema, no annotations), the description is inadequate. It doesn't explain what the plot outputs, how to interpret it, or critical behavioral aspects, leaving significant gaps for an AI agent to use it effectively.

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 fully documents all 19 parameters. The description adds no parameter-specific information beyond the schema, but the high coverage justifies a baseline score of 3, as the schema does the heavy lifting.

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 states the tool creates a 'compact plot of expression of a list of genes,' which provides a basic purpose but is vague about the specific type of plot and lacks differentiation from sibling tools like pl_dotplot or pl_heatmap. It doesn't specify what 'tracksplot' means or how it differs from other plotting tools in the server.

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?

No guidance is provided on when to use this tool versus alternatives like pl_dotplot or pl_matrixplot. The description doesn't mention prerequisites, context, or exclusions, leaving the agent without usage direction.

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