Skip to main content
Glama

tsne

Visualize single-cell RNA sequencing data by reducing high-dimensional information into 2D or 3D plots for cluster analysis and pattern discovery.

Instructions

t-distributed stochastic neighborhood embedding (t-SNE), for visualizating single-cell data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
n_pcsNoNumber of PCs to use. If None, automatically determined.
use_repNoKey for .obsm to use as representation.
perplexityNoRelated to number of nearest neighbors, typically between 5-50.
early_exaggerationNoControls space between natural clusters in embedded space.
learning_rateNoLearning rate for optimization, typically between 100-1000.
random_stateNoRandom seed for reproducibility.
use_fast_tsneNoWhether to use Multicore-tSNE implementation.
n_jobsNoNumber of jobs for parallel computation.
metricNoDistance metric to use.euclidean

Implementation Reference

  • Pydantic model defining the input schema and validation for the tsne tool.
    class TSNEModel(JSONParsingModel):
        """Input schema for the t-SNE dimensionality reduction tool."""
        n_pcs: Optional[int] = Field(
            default=None,
            description="Number of PCs to use. If None, automatically determined.",
            ge=0
        )
        use_rep: Optional[str] = Field(
            default=None,
            description="Key for .obsm to use as representation."
        )
        perplexity: Union[float, int] = Field(
            default=30,
            description="Related to number of nearest neighbors, typically between 5-50.",
            gt=0
        )
        early_exaggeration: Union[float, int] = Field(
            default=12,
            description="Controls space between natural clusters in embedded space.",
            gt=0
        )
        learning_rate: Union[float, int] = Field(
            default=1000,
            description="Learning rate for optimization, typically between 100-1000.",
            gt=0
        )
        random_state: int = Field(
            default=0,
            description="Random seed for reproducibility."
        )
        use_fast_tsne: bool = Field(
            default=False,
            description="Whether to use Multicore-tSNE implementation."
        )
        n_jobs: Optional[int] = Field(
            default=None,
            description="Number of jobs for parallel computation.",
            gt=0
        )
        metric: str = Field(
            default='euclidean',
            description="Distance metric to use."
        )
        
        @field_validator('n_pcs', 'perplexity', 'early_exaggeration', 
                       'learning_rate', 'n_jobs')
        def validate_positive_numbers(cls, v: Optional[Union[int, float]]) -> Optional[Union[int, float]]:
            """Validate positive numbers where applicable"""
            if v is not None and v <= 0:
                raise ValueError("must be a positive number")
            return v
        
        @field_validator('metric')
        def validate_metric(cls, v: str) -> str:
            """Validate distance metric is supported"""
            valid_metrics = ['euclidean', 'cosine', 'manhattan', 'l1', 'l2']
            if v.lower() not in valid_metrics:
                raise ValueError(f"metric must be one of {valid_metrics}")
            return v.lower()
  • Definition of the MCP Tool object for 'tsne', including name, description, and schema reference.
    # Define t-SNE tool
    tsne_tool = types.Tool(
        name="tsne",
        description="t-distributed stochastic neighborhood embedding (t-SNE), for visualizating single-cell data",
        inputSchema=TSNEModel.model_json_schema(),
    )
  • Dictionary mapping 'tsne' tool name to the underlying scanpy function sc.tl.tsne used in execution.
    tl_func = {
        "tsne": sc.tl.tsne,
        "umap": sc.tl.umap,
        "draw_graph": sc.tl.draw_graph,
        "diffmap": sc.tl.diffmap,
        "embedding_density": sc.tl.embedding_density,
        "leiden": sc.tl.leiden,
        "louvain": sc.tl.louvain,
        "dendrogram": sc.tl.dendrogram,
        "dpt": sc.tl.dpt,
        "paga": sc.tl.paga,
        "ingest": sc.tl.ingest,
        "rank_genes_groups": sc.tl.rank_genes_groups,
        "filter_rank_genes_groups": sc.tl.filter_rank_genes_groups,
        "marker_gene_overlap": sc.tl.marker_gene_overlap,
        "score_genes": sc.tl.score_genes,
        "score_genes_cell_cycle": sc.tl.score_genes_cell_cycle,
    }
  • Dictionary registering the tsne_tool (and other tl tools) that is used by the MCP server for tool listing and dispatch.
    tl_tools = {
        "tsne": tsne_tool,
        "umap": umap_tool,
        "draw_graph": draw_graph_tool,
        "diffmap": diffmap_tool,
        "embedding_density": embedding_density_tool,
        "leiden": leiden_tool,
        "louvain": louvain_tool,
        "dendrogram": dendrogram_tool,
        "dpt": dpt_tool,
        "paga": paga_tool,
        "ingest": ingest_tool,
        "rank_genes_groups": rank_genes_groups_tool,
        "filter_rank_genes_groups": filter_rank_genes_groups_tool,
        "marker_gene_overlap": marker_gene_overlap_tool,
        "score_genes": score_genes_tool,
        "score_genes_cell_cycle": score_genes_cell_cycle_tool,
    }
  • Handler function that executes tl tools like tsne by calling the mapped scanpy function with validated arguments and logging.
    def run_tl_func(ads, func, arguments):
        adata = ads.adata_dic[ads.active]
        if func not in tl_func:
            raise ValueError(f"Unsupported function: {func}")
        run_func = tl_func[func]
        parameters = inspect.signature(run_func).parameters
        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 Exception as e:
            logger.error(f"Error running function {func}: {e}")
            raise
        return 
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the algorithm purpose but doesn't describe what the tool actually does behaviorally - whether it modifies data in place, creates new embeddings, requires specific data formats, has computational intensity, or produces visual output versus coordinate data. The description is insufficient for a 9-parameter computational tool with no annotation coverage.

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 extremely concise - a single sentence that efficiently states both the algorithm name and its application domain. There's zero wasted verbiage, and it's front-loaded with the 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?

For a complex dimensionality reduction tool with 9 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what the tool returns (embeddings? plots?), how results integrate with the data structure, computational requirements, or typical workflow context. The single sentence leaves too many open questions for effective agent usage.

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 9 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. According to guidelines, when schema coverage is high (>80%), the baseline is 3 even with no param info in description.

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 performs 't-distributed stochastic neighborhood embedding (t-SNE)' and specifies its purpose 'for visualizing single-cell data.' This provides a specific verb (embedding) and resource (single-cell data), though it doesn't explicitly differentiate from sibling tools like umap or pca that also perform dimensionality reduction for visualization.

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 like umap, pca, or diffmap from the sibling list. It doesn't mention typical use cases, prerequisites, or comparisons with other dimensionality reduction methods available on the server.

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