find_similar_terms
Discover terms similar to a specified term within biological and medical ontologies using LLM embeddings. Input a term IRI and ontology identifier to retrieve a JSON list of related terms.
Instructions
Find terms similar to the given term using LLM embeddings.
Args: term_iri: The IRI of the reference term ontology: The ontology identifier size: Maximum number of similar terms to return
Returns: JSON formatted list of similar terms
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ontology | Yes | ||
| size | No | ||
| term_iri | Yes |
Implementation Reference
- src/ols_mcp_server/server.py:257-290 (handler)The handler function for the 'find_similar_terms' tool, registered via @mcp.tool(). It encodes the term IRI, queries the OLS API for similar terms using LLM embeddings at the /llm_similar endpoint, formats the response, and handles errors.@mcp.tool() async def find_similar_terms( term_iri: str, ontology: str, size: int = 10 ) -> str: """Find terms similar to the given term using LLM embeddings. Args: term_iri: The IRI of the reference term ontology: The ontology identifier size: Maximum number of similar terms to return Returns: JSON formatted list of similar terms """ encoded_iri = url_encode_iri(term_iri) params: dict[str, Any] = { "page": 0, "size": size } url = f"{OLS_BASE_URL}/api/v2/ontologies/{ontology}/classes/{encoded_iri}/llm_similar" 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 finding similar terms: {str(e)}"