get_term_children
Retrieve direct child terms of a specific ontology term using its IRI and ontology identifier, with options to include obsolete entities and limit results. Outputs in JSON.
Instructions
Get direct children of a specific term.
Args: term_iri: The IRI of the term ontology: The ontology identifier include_obsolete: Include obsolete entities size: Maximum number of results
Returns: JSON formatted list of child terms
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| include_obsolete | No | ||
| ontology | Yes | ||
| size | No | ||
| term_iri | Yes |
Implementation Reference
- src/ols_mcp_server/server.py:182-217 (handler)The primary handler function for the 'get_term_children' tool. It is decorated with @mcp.tool(), which registers it with the FastMCP server. The function makes an API call to the Ontology Lookup Service (OLS) to retrieve direct children of a specified term IRI within an ontology, formats the response, and handles errors.async def get_term_children( term_iri: str, ontology: str, include_obsolete: bool = False, size: int = 20 ) -> str: """Get direct children of a specific term. Args: term_iri: The IRI of the term ontology: The ontology identifier include_obsolete: Include obsolete entities size: Maximum number of results Returns: JSON formatted list of child terms """ encoded_iri = url_encode_iri(term_iri) params: dict[str, Any] = { "page": 0, "size": size, "includeObsoleteEntities": include_obsolete } url = f"{OLS_BASE_URL}/api/v2/ontologies/{ontology}/classes/{encoded_iri}/children" try: response = await client.get(url, params=params) response.raise_for_status() data = response.json() return format_response(data, size) except httpx.HTTPError as e: return f"Error getting term children: {str(e)}"