Skip to main content
Glama

get_template

Retrieve and transform template data from the CEDAR metadata repository by providing a template ID or URL for biomedical data annotation workflows.

Instructions

Get a template from the CEDAR repository.

Args: template_id: The template ID or full URL from CEDAR repository (e.g., "https://repo.metadatacenter.org/templates/e019284e-48d1-4494-bc83-ddefd28dfbac")

Returns: Template data from CEDAR, cleaned and transformed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
template_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration and handler for the 'get_template' MCP tool using @mcp.tool() decorator. Fetches template from CEDAR API and applies cleaning.
    @mcp.tool()
  • Helper function clean_template_response that transforms and cleans the raw CEDAR template JSON-LD into a simplified structure using Pydantic models for output schema validation.
    def clean_template_response(
        template_data: Dict[str, Any], bioportal_api_key: str
    ) -> Dict[str, Any]:
        """
        Clean and transform the raw CEDAR template JSON-LD to simplified YAML structure.
        Now supports nested objects, arrays, and template elements.
    
        Args:
            template_data: Raw template data from CEDAR (JSON-LD format)
            bioportal_api_key: BioPortal API key for fetching controlled term values
        Returns:
            Cleaned and transformed template data as dictionary (ready for YAML export)
        """
        # Extract template name, preferring schema:name for correct casing
        template_name = template_data.get("schema:name", "")
        if not template_name:
            # Fallback to title if schema:name is empty
            title = template_data.get("title", "")
            template_name = (
                title.replace(" template schema", "").replace("template schema", "").strip()
            )
            if not template_name:
                template_name = "Unnamed Template"
    
        # Get field order from UI configuration
        ui_config = template_data.get("_ui", {})
        field_order = ui_config.get("order", [])
    
        # Get properties section
        properties = template_data.get("properties", {})
    
        # Transform fields and elements in the specified order
        output_children: List[Union[FieldDefinition, ElementDefinition]] = []
    
        # Process fields/elements only in UI order since it covers all template items
        for item_name in field_order:
            if item_name in properties:
                item_data = properties[item_name]
                if isinstance(item_data, dict):
                    item_type = item_data.get("@type", "")
    
                    if item_type == "https://schema.metadatacenter.org/core/TemplateField":
                        # It's a simple field
                        field_child = _transform_field(
                            item_name, item_data, bioportal_api_key
                        )
                        output_children.append(field_child)
                    elif (
                        item_type
                        == "https://schema.metadatacenter.org/core/TemplateElement"
                    ):
                        # It's a template element (possibly an array)
                        element_child = _transform_element(
                            item_name, item_data, bioportal_api_key
                        )
                        output_children.append(element_child)
                    elif item_data.get("type") == "array" and "items" in item_data:
                        # It's an array - check what type of items it contains
                        items_type = item_data["items"].get("@type", "")
                        if (
                            items_type
                            == "https://schema.metadatacenter.org/core/TemplateField"
                        ):
                            # Array of fields - treat as a field with array marker
                            field_child = _transform_field(
                                item_name, item_data, bioportal_api_key
                            )
                            output_children.append(field_child)
                        elif (
                            items_type
                            == "https://schema.metadatacenter.org/core/TemplateElement"
                        ):
                            # Array of elements - treat as an element
                            element_child = _transform_element(
                                item_name, item_data, bioportal_api_key
                            )
                            output_children.append(element_child)
    
        # Create output template
        output_template = SimplifiedTemplate(
            type="template", name=template_name, children=output_children
        )
    
        # Convert to dictionary for YAML export
        return output_template.model_dump(exclude_none=True)
  • Pydantic model defining the output schema for cleaned templates, used by clean_template_response.
    class SimplifiedTemplate(BaseModel):
        """
        Represents the complete simplified template structure.
        """
    
        type: str = Field("template", description="Template type")
        name: str = Field(..., description="Template name")
        children: List[Union[FieldDefinition, ElementDefinition]] = Field(
            ..., description="Template fields and elements"
        )
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the template data is 'cleaned and transformed', which adds useful context about post-processing behavior. However, it lacks details on authentication needs, rate limits, or error handling, which are important for a retrieval tool.

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 appropriately sized and front-loaded with the main purpose, followed by structured sections for args and returns. Each sentence adds value, such as the example and transformation note, with no wasted words, though it could be slightly more streamlined.

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

Completeness4/5

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

Given the tool's low complexity (one parameter) and the presence of an output schema, the description is reasonably complete. It covers the purpose, parameter semantics, and return behavior, though it could benefit from more usage guidelines and behavioral details to be fully comprehensive.

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?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains that 'template_id' can be an ID or full URL, provides an example, and clarifies the format, compensating well for the schema's lack of documentation. With only one parameter, this is effective.

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

Purpose4/5

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

The description clearly states the verb 'Get' and resource 'template from the CEDAR repository', making the purpose understandable. However, it doesn't explicitly differentiate from the sibling tool 'get_instances_based_on_template', which appears to retrieve instances rather than templates, so this is a minor gap in sibling differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. The description mentions retrieving a template but doesn't clarify scenarios where this is preferred over other methods or tools, such as the sibling tool for instances, leaving the agent without usage context.

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/BACH-AI-Tools/cedar-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server