Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_cell_ontology_terms

Search for standardized cell ontology terms using controlled vocabulary to identify cell types like T cells or neurons in biomedical research.

Instructions

Search OLS for Cell Ontology (CL) terms using a controlled vocabulary for cell types.

Returns: dict: Cell ontology terms with cl_terms array containing id, label, definition, synonyms or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cell_typeYesCell type to search for (e.g., 'T cell', 'neuron')
sizeNoMaximum number of results to return
exact_matchNoWhether to perform exact match search

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the tool logic. Queries the OLS API (https://www.ebi.ac.uk/ols4/api/v2/entities) for Cell Ontology (CL) terms matching the cell_type, filters for CL: prefixed terms, and returns structured data including id, label, definition, synonyms, etc.
    @core_mcp.tool()
    def get_cell_ontology_terms(
        cell_type: Annotated[str, Field(description="Cell type to search for (e.g., 'T cell', 'neuron')")],
        size: Annotated[
            int,
            Field(description="Maximum number of results to return"),
        ] = 10,
        exact_match: Annotated[
            bool,
            Field(description="Whether to perform exact match search"),
        ] = False,
    ) -> Dict[str, Any]:
        """Search OLS for Cell Ontology (CL) terms using a controlled vocabulary for cell types.
    
        Returns:
            dict: Cell ontology terms with cl_terms array containing id, label, definition, synonyms or error message.
        """
        if not cell_type:
            return {"error": "cell_type must be provided"}
    
        url = "https://www.ebi.ac.uk/ols4/api/v2/entities"
    
        params = {
            "search": cell_type,
            "size": str(size),
            "lang": "en",
            "exactMatch": str(exact_match).lower(),
            "includeObsoleteEntities": "false",
            "ontologyId": "cl",
        }
    
        def starts_with_cl_prefix(curie: str) -> bool:
            """Check if the curie starts with CL prefix."""
            return curie.startswith("CL:")
    
        try:
            response = requests.get(url, params=params)
            response.raise_for_status()
    
            data = response.json()
    
            # Check that at least one item is in elements with CL prefix
            if not data.get("elements") or not any(
                starts_with_cl_prefix(str(element.get("curie", ""))) for element in data["elements"]
            ):
                return {"error": "No Cell Ontology terms found"}
    
            # Extract Cell Ontology terms with detailed information
            cl_terms = [
                {
                    "id": element["curie"].replace(":", "_"),
                    "label": element.get("label", ""),
                    "definition": element.get("definition", ""),
                    "synonyms": element.get("synonym", []),
                    "ontology_name": element.get("ontologyName", ""),
                    "is_defining_ontology": element.get("isDefiningOntology", False),
                    "has_hierarchical_children": element.get("hasHierarchicalChildren", False),
                    "has_hierarchical_parents": element.get("hasHierarchicalParents", False),
                    "num_descendants": element.get("numDescendants", 0),
                }
                for element in data["elements"]
                if starts_with_cl_prefix(str(element.get("curie", "")))
            ]
            return {"cl_terms": cl_terms}
    
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch Cell Ontology terms: {e!s}"}
  • Pydantic schema definitions for input parameters using Annotated and Field, and output as Dict[str, Any].
    def get_cell_ontology_terms(
        cell_type: Annotated[str, Field(description="Cell type to search for (e.g., 'T cell', 'neuron')")],
        size: Annotated[
            int,
            Field(description="Maximum number of results to return"),
        ] = 10,
        exact_match: Annotated[
            bool,
            Field(description="Whether to perform exact match search"),
        ] = False,
    ) -> Dict[str, Any]:
  • Registers core_mcp (containing the tool) into the main mcp_app with prefix=slugify('BC')='bc', resulting in the tool name 'bc_get_cell_ontology_terms'.
    for mcp in [core_mcp, *(await get_openapi_mcps())]:
        await mcp_app.import_server(
            mcp,
            slugify(mcp.name),
        )
    logger.info("MCP server setup complete.")
  • Imports all OLS tools (including get_cell_ontology_terms), ensuring their decorators register them in core_mcp.
    from .ols import *
  • Imports the handler function, triggering its @core_mcp.tool() decorator to register it in core_mcp.
    from ._get_cell_ontology_terms import get_cell_ontology_terms
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 return format (dict with cl_terms array or error message) which is helpful, but doesn't describe important behavioral aspects like whether this is a read-only operation, potential rate limits, authentication requirements, or what happens with partial matches. The description adds some value but leaves significant gaps for a search tool.

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 appropriately concise with two sentences that each serve distinct purposes: the first states the tool's purpose, the second describes the return format. There's no wasted language, though the structure could be slightly improved by front-loading the most critical information more explicitly.

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

Completeness4/5

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

Given the tool has an output schema (implied by 'Has output schema: true'), the description doesn't need to explain return values in detail. For a search tool with good schema coverage and output schema, the description provides adequate context about what it searches and what it returns, though it could benefit from more behavioral guidance.

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 fully documents all three parameters. The description doesn't add any parameter-specific information beyond what's in the schema - it doesn't explain how 'cell_type' interacts with 'exact_match', or provide examples of effective search strategies. The baseline of 3 is appropriate when the schema does all the parameter documentation work.

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 searches OLS for Cell Ontology terms using controlled vocabulary for cell types, which is a specific verb ('search') and resource ('OLS for Cell Ontology terms'). It distinguishes from most siblings that search different databases or ontologies, though it doesn't explicitly differentiate from 'bc_search_ontology_terms' which might be a broader alternative.

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. The description doesn't mention when this specific Cell Ontology search is appropriate compared to other ontology search tools like 'bc_search_ontology_terms' or 'bc_get_chebi_terms_by_chemical', nor does it provide any context about prerequisites or typical use cases.

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/biocontext-ai/knowledgebase-mcp'

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