Skip to main content
Glama

pl_pca

Create scatter plots in PCA coordinates to visualize single-cell RNA sequencing data patterns and relationships between samples.

Instructions

Scatter plot in PCA coordinates. default figure for PCA plot

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.
colorNoKeys for annotations of observations/cells or variables/genes.
gene_symbolsNoColumn name in .var DataFrame that stores gene symbols.
use_rawNoUse .raw attribute of adata for coloring with gene expression.
sort_orderNoFor continuous annotations used as color parameter, plot data points with higher values on top of others.
edgesNoShow edges between nodes.
edges_widthNoWidth of edges.
edges_colorNoColor of edges.grey
neighbors_keyNoWhere to look for neighbors connectivities.
arrowsNoShow arrows.
groupsNoRestrict to a few categories in categorical observation annotation.
componentsNoFor instance, ['1,2', '2,3']. To plot all available components use components='all'.
dimensionsNo0-indexed dimensions of the embedding to plot as integers. E.g. [(0, 1), (1, 2)].
layerNoName of the AnnData object layer that wants to be plotted.
projectionNoProjection of plot.2d
sizeNoPoint size. If None, is automatically computed.
frameonNoDraw a frame around the scatter plot.
add_outlineNoAdd outline to scatter plot points.
ncolsNoNumber of columns for multiple plots.
markerNoMatplotlib marker style for points..
annotate_var_explainedNoAnnotate the explained variance.

Implementation Reference

  • PCAModel defines the input schema (Pydantic model) for the pl_pca tool, inheriting from BaseEmbeddingModel.
    class PCAModel(BaseEmbeddingModel):
        """Input schema for the PCA plotting tool."""
        
        annotate_var_explained: bool = Field(
            default=False,
            description="Annotate the explained variance."
        )
  • Creates and registers the MCP Tool object for pl_pca with name, description, and input schema.
    pl_pca_tool = types.Tool(
        name="pl_pca",
        description="Scatter plot in PCA coordinates. default figure for PCA plot",
        inputSchema=PCAModel.model_json_schema(),
    )
  • Dictionary mapping tool names like 'pl_pca' to their corresponding Scanpy plotting functions (sc.pl.pca). Used by the handler.
    pl_func = {
        "pl_pca": sc.pl.pca,
        "pl_embedding": sc.pl.embedding,  # Add the new embedding function
        "diffmap": sc.pl.diffmap,
        "pl_violin": sc.pl.violin,
        "pl_stacked_violin": sc.pl.stacked_violin,
        "pl_heatmap": sc.pl.heatmap,
        "pl_dotplot": sc.pl.dotplot,
        "pl_matrixplot": sc.pl.matrixplot,
        "pl_tracksplot": sc.pl.tracksplot,
        "pl_scatter": sc.pl.scatter,
        "embedding_density": sc.pl.embedding_density,
        "rank_genes_groups": sc.pl.rank_genes_groups,
        "pl_rank_genes_groups_dotplot": sc.pl.rank_genes_groups_dotplot,  # Add function mapping
        "pl_clustermap": sc.pl.clustermap,
        "pl_highly_variable_genes": sc.pl.highly_variable_genes,
        "pl_pca_variance_ratio": sc.pl.pca_variance_ratio,
    }
  • Handler function that executes the pl_pca tool: retrieves adata, prepares kwargs from arguments, calls sc.pl.pca(adata, **kwargs), saves figure, logs operation, returns fig_path.
    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
  • MCP server call_tool handler dispatches to run_pl_func when tool name is in pl_tools (includes pl_pca).
    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})
                )
            ]
Behavior1/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 fails completely. It doesn't mention that this is a visualization/read-only operation (implied but not stated), doesn't describe what the output looks like (no output schema exists), doesn't mention performance characteristics, data requirements, or any side effects. For a complex 30-parameter visualization tool, this is critically inadequate.

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 extremely concise (two short phrases) but this brevity comes at the cost of being under-specified rather than efficient. While it's not verbose or repetitive, it fails to provide essential information that would help an AI agent understand and use the tool effectively. The structure is simple but inadequate for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's high complexity (30 parameters), lack of annotations, and absence of an output schema, the description is completely inadequate. It doesn't explain what PCA coordinates are being plotted, what data format is expected, what the visualization output contains, or how this tool relates to the data analysis workflow. For such a sophisticated visualization tool, this minimal description fails to provide necessary context.

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 schema description coverage is 100%, so all parameters are documented in the schema itself. The description adds no parameter information beyond what's already in the comprehensive schema. According to the scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter information in the description, which applies here.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Scatter plot in PCA coordinates. default figure for PCA plot' is vague and tautological. It restates the tool name 'pl_pca' (plot PCA) without specifying what it actually does - it doesn't clarify that this visualizes principal component analysis results as a scatter plot, nor does it distinguish it from sibling tools like 'pl_scatter' or 'pl_embedding'. The phrase 'default figure for PCA plot' adds confusion rather than clarity.

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

Usage Guidelines1/5

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

There are absolutely no usage guidelines provided. The description doesn't indicate when to use this tool versus alternatives like 'pl_scatter', 'pl_embedding', or 'pl_pca_variance_ratio' (all sibling tools). It offers no context about prerequisites, when this visualization is appropriate, or what data state is required before calling this tool.

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