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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes |
Implementation Reference
- src/ols_mcp_server/server.py:154-178 (handler)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)}"
- src/ols_mcp_server/models.py:26-40 (schema)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")
- src/ols_mcp_server/server.py:154-154 (registration)The @mcp.tool() decorator registers the get_term_info function as an MCP tool in the FastMCP server.@mcp.tool()