Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_go_terms_by_gene

Retrieve Gene Ontology terms associated with specific genes to understand their biological functions, processes, and cellular components using structured vocabularies.

Instructions

Search OLS for Gene Ontology (GO) terms related to a gene name using structured vocabularies.

Returns: dict: GO terms with go_terms array containing id, label, description, type or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gene_nameYesGene name or symbol to search for (e.g., 'TP53', 'BRCA1')
sizeNoMaximum number of results to return
exact_matchNoWhether to perform exact match search

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'bc_get_go_terms_by_gene' tool. It queries the OLS API with the gene name filtered to the 'go' ontology, extracts GO-prefixed terms, and formats them into a 'go_terms' list with id, label, description, ontology_name, and type.
    @core_mcp.tool()
    def get_go_terms_by_gene(
        gene_name: Annotated[str, Field(description="Gene name or symbol to search for (e.g., 'TP53', 'BRCA1')")],
        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 Gene Ontology (GO) terms related to a gene name using structured vocabularies.
    
        Returns:
            dict: GO terms with go_terms array containing id, label, description, type or error message.
        """
        if not gene_name:
            return {"error": "gene_name must be provided"}
    
        url = "https://www.ebi.ac.uk/ols4/api/v2/entities"
    
        params = {
            "search": gene_name,
            "size": str(size),
            "lang": "en",
            "exactMatch": str(exact_match).lower(),
            "includeObsoleteEntities": "false",
            "ontologyId": "go",
        }
    
        def starts_with_go_prefix(curie: str) -> bool:
            """Check if the curie starts with GO prefix."""
            return curie.startswith("GO:")
    
        try:
            response = requests.get(url, params=params)
            response.raise_for_status()
    
            data = response.json()
    
            # Check that at least one item is in elements with GO prefix
            if not data.get("elements") or not any(
                starts_with_go_prefix(str(element.get("curie", ""))) for element in data["elements"]
            ):
                return {"error": "No GO terms found"}
    
            # Extract GO terms and their information
            go_terms = [
                {
                    "id": element["curie"].replace(":", "_"),
                    "label": element["label"],
                    "description": element.get("description", ""),
                    "ontology_name": element.get("ontologyName", ""),
                    "type": element.get("type", ""),
                }
                for element in data["elements"]
                if starts_with_go_prefix(str(element.get("curie", "")))
            ]
            return {"go_terms": go_terms}
    
        except requests.exceptions.RequestException as e:
            return {"error": f"Failed to fetch GO terms: {e!s}"}
  • Explicit import of the handler function into the OLS module namespace.
    from ._get_go_terms_by_gene import get_go_terms_by_gene
  • Wildcard import of OLS tools into the core_mcp FastMCP server namespace, registering 'get_go_terms_by_gene' as 'bc_get_go_terms_by_gene' due to server prefix.
    from .ols import *
  • Import of the core_mcp server instance used for the @tool decorator to register the function.
    from biocontext_kb.core._server import core_mcp
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It mentions the return format ('dict: GO terms with go_terms array...') but lacks details on error handling, rate limits, authentication needs, or what 'search OLS' entails operationally. This is inadequate for a tool with potential complexity in ontology searching.

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: one stating the purpose and another specifying the return format. It is front-loaded with the core functionality, though the second sentence could be integrated more smoothly. There is no wasted verbiage.

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 the tool's complexity (ontology searching), 100% schema coverage, and presence of an output schema, the description is minimally adequate. However, it lacks context on usage scenarios, error conditions, or behavioral traits, which are important for an agent to invoke it correctly in varied contexts.

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%, providing clear documentation for all parameters (gene_name, size, exact_match). The description adds no additional parameter semantics beyond what the schema already explains, such as search behavior or result formatting, so it meets the baseline for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('Search OLS for Gene Ontology (GO) terms related to a gene name') and resource ('using structured vocabularies'), distinguishing it from sibling tools like bc_search_ontology_terms or bc_get_term_details. It explicitly identifies the target (GO terms) and input (gene name), making the purpose unambiguous.

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 does not mention prerequisites, exclusions, or compare it to sibling tools such as bc_search_ontology_terms or bc_get_term_hierarchical_children, leaving the agent without context for tool selection.

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