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

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

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/BnJam/stac-mcp'

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