Skip to main content
Glama

get_xml_structure

Analyze the structure and metadata of Apple Health XML export files to identify root elements, record types, workout types, and data sources without loading full content for quick insights.

Instructions

Analyze the structure and metadata of an Apple Health XML export file without loading the entire content.

Returns:

  • file_size_mb: Size of the file in megabytes

  • root_elements: List of unique root-level XML tags

  • record_types: List of unique health record types (see RecordType for most frequent types, but may include others)

  • workout_types: List of unique workout types

  • sources: List of unique data sources (device/app names)

Notes for LLMs:

  • Use this to quickly understand the contents and structure of a health XML file

  • RecordType contains only the most frequent types; other types may appear as strings

  • Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function decorated with @tool that implements the get_xml_structure tool logic by delegating to analyze_xml_structure().
    @xml_reader_router.tool
    def get_xml_structure() -> dict[str, Any]:
        """
        Analyze the structure and metadata of an Apple Health XML export file
        without loading the entire content.
    
        Returns:
        - file_size_mb: Size of the file in megabytes
        - root_elements: List of unique root-level XML tags
        - record_types: List of unique health record types (see RecordType for
          most frequent types, but may include others)
        - workout_types: List of unique workout types
        - sources: List of unique data sources (device/app names)
    
        Notes for LLMs:
        - Use this to quickly understand the contents and structure of a health XML file
        - RecordType contains only the most frequent types; other types may appear as strings
        - Do not guess, auto-fill, or assume any missing data.
        - When asked for medical advice, try to use my data from ElasticSearch first.
        """
        try:
            return analyze_xml_structure()
        except Exception as e:
            return {"error": f"Failed to analyze XML structure: {str(e)}"}
  • Mounts the xml_reader_router (containing the get_xml_structure tool) to the main mcp_router, registering the tool.
    mcp_router.mount(xml_reader.xml_reader_router)
  • Core helper function that streams the XML file, analyzes its structure, collects metadata like record types, workout types, sources, and file size.
    def analyze_xml_structure() -> dict[str, Any]:
        xml_path = get_xml_path()
        structure = {
            "file_size_mb": round(xml_path.stat().st_size / (1024 * 1024), 2),
            "root_elements": set(),
            "record_types": set(),
            "workout_types": set(),
            "sources": set(),
        }
        for elem in stream_xml_elements():
            structure["root_elements"].add(elem.tag)
            if rt := extract_record_type(elem):
                structure["record_types"].add(rt)
            if wt := extract_workout_type(elem):
                structure["workout_types"].add(wt)
            if src := extract_source(elem):
                structure["sources"].add(src)
        # Convert sets to lists
        for k in ["root_elements", "record_types", "workout_types", "sources"]:
            structure[k] = list(structure[k])
        return structure
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by specifying what information is returned (file size, root elements, record types, etc.) and behavioral constraints ('Do not guess, auto-fill, or assume any missing data'). It also mentions medical advice guidance, though this is somewhat tangential to the tool's core function.

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 well-structured with clear sections (Returns, Notes for LLMs) and front-loaded with the core purpose. Some sentences in the Notes section could be more concise, but overall it's efficient and focused.

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

Completeness5/5

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

Given the tool's complexity (structural analysis of XML files), no annotations, but with an output schema present, the description provides complete context. It explains what the tool returns, usage guidance, and behavioral constraints, making it fully adequate for the agent to understand and use the tool correctly.

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 parameters and 100% schema coverage, the baseline is 4. The description appropriately explains that this tool analyzes an XML file without requiring input parameters, which adds value beyond the empty 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 ('Analyze the structure and metadata') and resource ('Apple Health XML export file') with explicit scope ('without loading the entire content'). It distinguishes from siblings by focusing on structural analysis rather than content retrieval or search operations.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('to quickly understand the contents and structure of a health XML file') and includes specific 'Notes for LLMs' with usage instructions. It implicitly distinguishes from siblings by focusing on metadata analysis rather than data extraction or search.

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

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/the-momentum/apple-health-mcp-server'

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