Skip to main content
Glama

get_health_summary_es

Retrieve a summary of Apple Health data from Elasticsearch, including total record count, type breakdown, and optional date range aggregation for analysis.

Instructions

Get a summary of Apple Health data from Elasticsearch. The function returns total record count, record type breakdown, and (optionally) a date range aggregation.

Notes for LLM:

  • IMPORTANT - 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

  • MCP tool handler for get_health_summary_es. Decorated with @es_reader_router.tool decorator for registration. Delegates to the helper function and handles exceptions.
    @es_reader_router.tool
    def get_health_summary_es() -> dict[str, Any]:
        """
        Get a summary of Apple Health data from Elasticsearch.
        The function returns total record count, record type breakdown, and
        (optionally) a date range aggregation.
    
        Notes for LLM:
        - IMPORTANT - Do not guess, autofill, or assume any missing data.
        - If there are multiple databases available (DuckDB, ClickHouse, Elasticsearch):
          first, ask the user which one he wants to use. DO NOT call any tools before
          the user specifies his intent.
        - If the user decides on an option, only use tools from this database,
          do not switch over to another until the user specifies that he wants
          to use a different one. You do not have to keep asking whether
          the user wants to use the same database that he used before.
        - If there is only one database available (DuckDB, ClickHouse, Elasticsearch):
          you can use the tools from this database without the user specifying it.
        """
        try:
            return get_health_summary_from_es()
        except Exception as e:
            return {"error": f"Failed to get health summary: {str(e)}"}
  • app/mcp/v1/mcp.py:9-9 (registration)
    Registration of the es_reader_router (containing the get_health_summary_es tool) by mounting it onto the main mcp_router.
    mcp_router.mount(es_reader.es_reader_router)
  • Core implementation logic that executes the Elasticsearch aggregation query to retrieve total record count and breakdown by record types.
    def get_health_summary_from_es() -> dict[str, Any]:
        query = {
            "size": 0,
            "aggs": {
                "total_records": {"value_count": {"field": "type.keyword"}},
                "record_types": {"terms": {"field": "type.keyword", "size": 50}},
            },
        }
        response = _run_es_query(query)
        total_records_value = response["aggregations"]["total_records"]["value"]
        record_types = {
            bucket["key"]: bucket["doc_count"]
            for bucket in response["aggregations"]["record_types"]["buckets"]
        }
        return {
            "total_records": total_records_value,
            "record_types": record_types,
            "index_name": settings.ES_INDEX,
        }
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 adds some context by specifying the return data types and an optional aggregation feature, but it doesn't cover important aspects like rate limits, authentication needs, or error handling. The LLM notes provide operational guidance but not behavioral traits.

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 and appropriately sized, with a clear purpose statement followed by specific return details and operational notes. Every sentence adds value, though the LLM notes could be more integrated into the main description rather than as a separate section.

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 has 0 parameters, an output schema exists, and no annotations, the description provides sufficient context for its purpose and usage. It explains what data is returned and includes operational guidance, though it could benefit from more behavioral details like performance characteristics or limitations.

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 tool has 0 parameters with 100% schema description coverage, so no parameter information is needed. The description appropriately doesn't discuss parameters, focusing instead on what the tool does and its output. This meets the baseline for tools with no parameters.

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 tool's purpose: 'Get a summary of Apple Health data from Elasticsearch' with specific details about what it returns (total record count, record type breakdown, and optional date range aggregation). It distinguishes from siblings by focusing on summary data rather than detailed statistics, trends, or search operations, though it doesn't explicitly name alternatives.

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

Usage Guidelines3/5

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

The description includes implicit usage guidance through the 'Notes for LLM' section, suggesting to use this data first when asked for medical advice. However, it lacks explicit when-to-use vs. when-not-to-use instructions or named alternatives to sibling tools like get_statistics_by_type_es or search_health_records_es.

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