Skip to main content
Glama
seandavi

OLS MCP Server

by seandavi

get_term_children

Retrieve direct child terms from biological ontologies by specifying a parent term IRI and ontology identifier to explore hierarchical relationships.

Instructions

Get direct children 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 child terms

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
term_iriYes
ontologyYes
include_obsoleteNo
sizeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'get_term_children' tool. It queries the OLS API to retrieve direct children of a specified term IRI within an ontology, handles URL encoding, makes the HTTP request, formats the response as JSON, and includes error handling.
    @mcp.tool()
    async def get_term_children(
        term_iri: str,
        ontology: str,
        include_obsolete: bool = False,
        size: int = 20
    ) -> str:
        """Get direct children 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 child 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}/children"
        
        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 children: {str(e)}"
  • Helper function used by get_term_children to double URL-encode the term IRI for compatibility with the OLS API path requirements.
    def url_encode_iri(iri: str) -> str:
        """Double URL encode an IRI as required by OLS API."""
        return urllib.parse.quote(urllib.parse.quote(iri, safe=""), safe="")
  • Helper function used by get_term_children (and other tools) to format paginated OLS API responses into a readable JSON structure with limited items and truncated descriptions.
    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 the return format ('JSON formatted list') but lacks critical details like whether this is a read-only operation, potential rate limits, authentication requirements, error conditions, or pagination behavior beyond the 'size' parameter.

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

Conciseness4/5

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

The description is efficiently structured with a clear purpose statement followed by organized sections for Args and Returns. Each sentence earns its place, though the Returns section could be slightly more informative about the structure of child terms.

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 (4 parameters, 2 required), no annotations, but with an output schema present, the description is adequate but has gaps. The output schema existence means return values don't need explanation, but behavioral aspects like safety, performance, and error handling remain undocumented.

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

Parameters4/5

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

With 0% schema description coverage, the description compensates well by explaining all 4 parameters in the Args section. It clarifies that 'term_iri' identifies the specific term, 'ontology' specifies the ontology identifier, 'include_obsolete' controls whether to include obsolete entities, and 'size' sets the maximum results. This adds meaningful context beyond the bare schema.

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

Purpose5/5

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

The description clearly states the specific action ('Get direct children') and resource ('of a specific term'), distinguishing it from siblings like get_term_ancestors (which goes upward) and get_term_info (which provides general info). The verb+resource combination is precise and unambiguous.

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 get_term_ancestors or search_terms. It mentions what the tool does but offers no context about appropriate use cases, prerequisites, or exclusions.

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