Skip to main content
Glama
seandavi

OLS MCP Server

by seandavi

search_ontologies

Search for available biological and medical ontologies to find relevant terminology and classifications for research or data annotation.

Instructions

Search for available ontologies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
searchNo
pageNo
sizeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function decorated with @mcp.tool() that implements the search_ontologies tool logic, querying the OLS v2 API and formatting the response.
    @mcp.tool()
    async def search_ontologies(
        search: Annotated[Optional[str], "Optional search query to filter ontologies"] = None,
        page: Annotated[int, "Page number for pagination (default: 0)"] = 0,
        size: Annotated[int, "Number of results per page (default: 20)"] = 20,
    ) -> list[OntologySearchResponse] | str:
        """Search for available ontologies."""
        params: dict[str, Any] = {
            "page": page,
            "size": size
        }
        
        if search:
            params["search"] = search
        
        url = f"{OLS_BASE_URL}/api/v2/ontologies"
        
        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 searching ontologies: {str(e)}"
  • Pydantic models defining the structured output type (OntologySearchResponse) used by the search_ontologies tool handler.
    class OntologyInfo(BaseModel):
        id: str = Field(..., description="Unique identifier for the ontology", alias="ontologyId")
        title: str = Field(..., description="Name of the ontology")
        version: Optional[str] = Field(None, description="Version of the ontology")
        description: Optional[str] = Field(None, description="Description of the ontology")
        domain: Optional[str] = Field(None, description="Domain of the ontology")
        homepage: Optional[HttpUrl] = Field(None, description="URL for the ontology")
        preferred_prefix: Optional[str] = Field(None, description="Preferred prefix for the ontology", alias="preferredPrefix")
        number_of_terms: Optional[int] = Field(None, description="Number of terms in the ontology")
        number_of_classes: Optional[int] = Field(None, description="Number of classes in the ontology", alias="numberOfClasses")
        repository: Optional[HttpUrl] = Field(None, description="Repository URL for the ontology")
        
    class PagedResponse(BaseModel):
        total_elements: int = Field(0, description="Total number of items", alias="totalElements")
        page: int = Field(0, description="Current page number")
        size: int = Field(20, description="Starting index of the current page", alias="numElements")
        total_pages: int = Field(0, description="Total number of pages", alias="totalPages")
        
    class OntologySearchResponse(PagedResponse):
        ontologies: list[OntologyInfo] = Field(..., description="List of ontologies matching the search criteria")
  • Utility function used by search_ontologies (and other tools) to format paginated OLS API responses into readable JSON.
    def format_response(data: Any, max_items: int = 10) -> str:
        """Format API response data for display."""
        if isinstance(data, dict):
            if "elements" in data:
                # Handle paginated response
                elements = data["elements"][:max_items]
                total = data.get("totalElements", len(elements))
                
                result = []
                for item in elements:
                    if isinstance(item, dict):
                        # Extract key fields for display
                        label = item.get("label", "")
                        iri = item.get("iri", "")
                        description = item.get("description", [])
                        if isinstance(description, list) and description:
                            description = description[0]
                        elif isinstance(description, list):
                            description = ""
                        
                        result.append({
                            "label": label,
                            "iri": iri,
                            "description": description[:200] + "..." if len(str(description)) > 200 else description
                        })
                
                return json.dumps({
                    "items": result,
                    "total_items": total,
                    "showing": len(result)
                }, indent=2)
            else:
                # Single item response
                return json.dumps(data, indent=2)
        
        return json.dumps(data, indent=2)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'search' but does not specify whether this is a read-only operation, how results are returned (e.g., paginated via 'page' and 'size'), or any limitations (e.g., rate limits). The description is minimal and fails to convey key behavioral traits beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It is appropriately sized for a simple tool and front-loads the core action, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no annotations, but with an output schema), the description is incomplete. It covers the basic purpose but lacks parameter explanations and behavioral context. The presence of an output schema mitigates the need to describe return values, but overall, the description does not provide enough information for confident tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It does not mention any parameters ('search', 'page', 'size') or their purposes, leaving all three undocumented. This is a significant gap, as the agent cannot infer parameter meanings from the description alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search for available ontologies' clearly states the verb ('search') and resource ('ontologies'), making the basic purpose understandable. However, it lacks specificity about what 'available' means or how this differs from sibling tools like 'search_terms' or 'get_ontology_info', leaving it somewhat vague in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_terms' (for terms within ontologies) or 'get_ontology_info' (for details on specific ontologies). Without any context about use cases or exclusions, the agent must infer usage from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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