Skip to main content
Glama
seandavi

OLS MCP Server

by seandavi

get_term_ancestors

Retrieve parent terms of a specific term in a given ontology using the OLS MCP Server. Input the term's IRI and ontology identifier to receive JSON-formatted ancestor terms, with options to include obsolete entities and set result size.

Instructions

Get ancestor terms (parents) 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 ancestor terms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
include_obsoleteNo
ontologyYes
sizeNo
term_iriYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the core logic for retrieving ancestor terms from the OLS API. Includes input parameters, API call construction, response formatting, and error handling.
    @mcp.tool() async def get_term_ancestors( term_iri: str, ontology: str, include_obsolete: bool = False, size: int = 20 ) -> str: """Get ancestor terms (parents) 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 ancestor 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}/ancestors" 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 ancestors: {str(e)}"

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/seandavi/ols-mcp-server'

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