Skip to main content
Glama
seandavi

OLS MCP Server

by seandavi

get_term_info

Retrieve detailed information about biological and medical terms using the Ontology Lookup Service (OLS) API, enabling accurate data access for AI assistants.

Instructions

Get detailed information about a specific term.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes

Implementation Reference

  • The main handler function for the 'get_term_info' tool. It is decorated with @mcp.tool() which handles both definition and registration in FastMCP. Retrieves detailed term information from the OLS API using the provided term ID (supports IRI, short form, or OBO ID). Validates and returns a DetailedTermInfo model or error string.
    @mcp.tool() async def get_term_info( id: Annotated[ str, ("Can be the IRI (Example : http://purl.obolibrary.org/obo/DUO_0000017)" ", short form (Example : DUO_0000017), or obo ID (Example: DUO:0000017) of the term") ], ) -> DetailedTermInfo | str: """Get detailed information about a specific term.""" url = f"{OLS_BASE_URL}/api/terms" try: response = await client.get(url, params={"id": id}) response.raise_for_status() data = response.json() embedded = data.get("_embedded", {}) if "terms" in embedded: terms = embedded["terms"] return DetailedTermInfo.model_validate(terms[0]) return f"Term with ID '{id}' not found in OLS." except httpx.HTTPError as e: return f"Error getting term info: {str(e)}"
  • Pydantic models defining the output schema for get_term_info. DetailedTermInfo extends TermInfo to include term description and synonyms, used for response validation.
    class TermInfo(BaseModel): iri: HttpUrl = Field(..., description="IRI of the term") ontology_name: str = Field(..., description="Name of the ontology containing the term") short_form: str = Field(..., description="Short form identifier for the term") label: str = Field(..., description="Human-readable label for the term") obo_id: Optional[str] = Field(None, description="OBOLibrary ID for the term", alias="oboId") is_obsolete: Optional[bool] = Field(False, description="Indicates if the term is obsolete") class TermSearchResponse(PagedResponse): num_found: int = Field(0, description="Total number of terms found", alias="numFound") terms: list[TermInfo] = Field(..., description="List of terms matching the search criteria") class DetailedTermInfo(TermInfo): description: Optional[list[str]] = Field(None, description="Definition of the term") synonyms: Optional[list[str]] = Field(None, description="List of synonyms for the term")
  • The @mcp.tool() decorator registers the get_term_info function as an MCP tool in the FastMCP server.
    @mcp.tool()

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