Skip to main content
Glama

get_aggregations

Calculate statistical aggregations for geospatial datasets by applying filters to STAC items across collections, bounding boxes, time ranges, and custom queries.

Instructions

Get aggregations for STAC items.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionsYes
bboxNo
datetimeNo
queryNo
catalog_urlNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the core logic of the 'get_aggregations' tool. It invokes STACClient.get_aggregations with parameters from arguments and formats the result as text or JSON.
    def handle_get_aggregations(
        client: STACClient,
        arguments: dict[str, Any],
    ) -> list[TextContent] | dict[str, Any]:
        data = client.get_aggregations(
            collections=arguments.get("collections"),
            ids=arguments.get("ids"),
            bbox=arguments.get("bbox"),
            intersects=arguments.get("intersects"),
            datetime=arguments.get("datetime"),
            query=arguments.get("query"),
            filter_lang=arguments.get("filter_lang"),
            filter_expr=arguments.get("filter"),
            fields=arguments.get("fields"),
            sortby=arguments.get("sortby"),
            limit=arguments.get("limit", 0),
        )
        if arguments.get("output_format") == "json":
            return {"type": "aggregations", **data}
    
        result_text = "**Aggregations**\n\n"
        result_text += f"Supported: {'Yes' if data.get('supported') else 'No'}\n"
        if data.get("aggregations"):
            result_text += "Aggregations:\n"
            for agg in data["aggregations"]:
                name = agg.get("name", "unnamed")
                value = agg.get("value", {})
                result_text += f"  - {name}:\n"
                if isinstance(value, dict):
                    for k, v in value.items():
                        result_text += f"    - {k}: {v}\n"
                else:
                    result_text += f"    - value: {value}\n"
        if data.get("meta"):
            result_text += f"\nMeta:\n  - Matched: {data['meta'].get('matched')}\n"
        result_text += f"\n{data.get('message', '')}\n"
        return [TextContent(type="text", text=result_text)]
  • The primary registration of the 'get_aggregations' tool using @app.tool decorator in FastMCP. The function signature defines the input schema and dispatches to the internal execution machinery.
    @app.tool
    async def get_aggregations(
        collections: list[str],
        bbox: list[float] | None = None,
        datetime: str | None = None,
        query: dict[str, Any] | None = None,
        catalog_url: str | None = None,
    ) -> list[dict[str, Any]]:
        """Get aggregations for STAC items."""
        return await execution.execute_tool(
            "get_aggregations",
            arguments={
                "collections": collections,
                "bbox": bbox,
                "datetime": datetime,
                "query": query,
            },
            catalog_url=catalog_url,
            headers=None,
        )
  • Internal registry in execution.py that maps the tool name 'get_aggregations' to its handler function handle_get_aggregations, used by execute_tool.
    _TOOL_HANDLERS: dict[str, Handler] = {
        "search_collections": handle_search_collections,
        "get_collection": handle_get_collection,
        "search_items": handle_search_items,
        "get_item": handle_get_item,
        "estimate_data_size": handle_estimate_data_size,
        "get_root": handle_get_root,
        "get_conformance": handle_get_conformance,
        "get_queryables": handle_get_queryables,
        "get_aggregations": handle_get_aggregations,
        "sensor_registry_info": handle_sensor_registry_info,
    }
  • Import of the get_aggregations handler into the execution module.
    from stac_mcp.tools.get_aggregations import handle_get_aggregations
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get aggregations' implies a read operation, but the description doesn't specify whether this is a computationally intensive operation, whether it requires specific permissions, what format the aggregations are returned in, or any rate limits. The description adds minimal behavioral context beyond the basic operation name.

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 extremely concise at just 5 words, with zero wasted language. It's front-loaded with the core purpose, though this comes at the expense of providing necessary details. Every word earns its place in communicating the basic function.

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

Completeness2/5

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

Given the complexity of 5 parameters with 0% schema coverage, no annotations, and multiple sibling tools, the description is insufficiently complete. While an output schema exists (which helps with return values), the description doesn't explain what 'aggregations' are, when to use this tool, or what the parameters mean. For a tool with this level of complexity and poor schema documentation, the description should do much more.

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?

With 0% schema description coverage and 5 parameters (1 required, 4 optional), the description provides no information about what any parameter means. 'collections', 'bbox', 'datetime', 'query', and 'catalog_url' are completely unexplained in the description, leaving the agent to guess their purpose and format based solely on parameter names.

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 states the tool 'Get aggregations for STAC items' which provides a basic verb+resource combination, but it's vague about what 'aggregations' means in this context. It doesn't distinguish this tool from its siblings like 'search_items' or 'get_item', leaving the agent uncertain about when to choose this specific tool over alternatives.

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. With siblings like 'search_items', 'get_item', and 'get_collection', the agent receives no indication about the specific use case for aggregations versus other data retrieval methods. There's no mention of prerequisites, constraints, or comparative 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/Wayfinder-Foundry/stac-mcp'

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