Skip to main content
Glama
biocontext-ai

BioContextAI Knowledgebase MCP

Official

bc_get_term_details

Retrieve detailed information about specific ontology terms, including definitions, synonyms, and hierarchical relationships, using term IDs and ontology IDs in CURIE format.

Instructions

Query the Ontology Lookup Service (OLS) for detailed information about a specific term.

This function retrieves comprehensive information about a specific ontology term, including its definition, synonyms, hierarchical relationships, and cross-references.

Args: term_id (str): The term ID in CURIE format (e.g., "EFO:0000001"). ontology_id (str): The ontology ID (e.g., "efo").

Returns: dict: Dictionary containing detailed term information or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ontology_idYesThe ontology ID where the term is defined (e.g., 'efo', 'go', 'chebi')
term_idYesThe term ID (CURIE) to get details for (e.g., 'EFO:0000001', 'GO:0008150')

Implementation Reference

  • The core handler function for the 'bc_get_term_details' tool (prefixed from 'get_term_details'). Implements API call to EBI OLS for term details, with Pydantic-typed inputs defining the schema.
    @core_mcp.tool() def get_term_details( term_id: Annotated[str, Field(description="Term ID in CURIE format (e.g., 'EFO:0000001', 'GO:0008150')")], ontology_id: Annotated[ str, Field(description="Ontology ID where the term is defined (e.g., 'efo', 'go', 'chebi')") ], ) -> Dict[str, Any]: """Get comprehensive details about a specific ontology term including definition, synonyms, hierarchical relationships. Returns: dict: Term details with id, label, definition, synonyms, hierarchical info, num_descendants or error message. """ if not term_id: return {"error": "term_id must be provided"} if not ontology_id: return {"error": "ontology_id must be provided"} # Double URL encode the term IRI import urllib.parse term_iri = f"http://purl.obolibrary.org/obo/{term_id.replace(':', '_')}" encoded_iri = urllib.parse.quote(urllib.parse.quote(term_iri, safe=""), safe="") url = f"https://www.ebi.ac.uk/ols4/api/v2/ontologies/{ontology_id}/entities/{encoded_iri}" try: response = requests.get(url) response.raise_for_status() data = response.json() if not data: return {"error": "Term not found"} # Extract comprehensive term information term_details = { "id": data.get("curie", "").replace(":", "_"), "curie": data.get("curie", ""), "label": data.get("label", ""), "definition": data.get("definition", ""), "synonyms": data.get("synonym", []), "ontology_name": data.get("ontologyName", ""), "ontology_prefix": data.get("ontologyPrefix", ""), "is_defining_ontology": data.get("isDefiningOntology", False), "is_obsolete": data.get("isObsolete", False), "is_preferred_root": data.get("isPreferredRoot", False), "has_hierarchical_children": data.get("hasHierarchicalChildren", False), "has_hierarchical_parents": data.get("hasHierarchicalParents", False), "has_direct_children": data.get("hasDirectChildren", False), "has_direct_parents": data.get("hasDirectParents", False), "num_descendants": data.get("numDescendants", 0), "num_hierarchical_descendants": data.get("numHierarchicalDescendants", 0), "appears_in": data.get("appearsIn", []), "defined_by": data.get("definedBy", []), "imported": data.get("imported", False), } return {"term_details": term_details} except requests.exceptions.RequestException as e: return {"error": f"Failed to fetch term details: {e!s}"}
  • Registers tools from core_mcp (including bc_get_term_details) into the main MCP application with namespace prefix 'bc' generated by slugify('BC').
    for mcp in [core_mcp, *(await get_openapi_mcps())]: await mcp_app.import_server( mcp, slugify(mcp.name), )
  • Imports the OLS module, triggering registration of 'get_term_details' tool on the core_mcp instance via import in ols/__init__.py.
    from .ols import *
  • Utility function used to generate the 'bc' prefix for namespacing core tools as 'bc_*' in the main MCP app.
    def slugify(name: str) -> str: """Slugify a name by replacing spaces with underscores and converting to lowercase. Allow only alphanumeric characters and underscores. """ return "".join(c if c.isalnum() else "-" for c in name.strip().replace(" ", "-").lower())

Other Tools

Related 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