Skip to main content
Glama

get_collection

Retrieve detailed metadata for a specific STAC collection to access geospatial datasets like satellite imagery and weather data.

Instructions

Get detailed information about a specific STAC collection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalog_urlNoSTAC catalog URL (optional, defaults to Microsoft Planetary Computer)
collection_idYesID of the collection to retrieve

Implementation Reference

  • The core handler function `handle_get_collection` that implements the tool logic: fetches the collection via STACClient, handles JSON/text output formatting, and generates a descriptive markdown summary.
    def handle_get_collection( client: STACClient, arguments: dict[str, Any], ) -> list[TextContent] | dict[str, Any]: collection_id = arguments["collection_id"] collection = client.get_collection(collection_id) if collection is None: return {"type": "collection", "collection": None} if arguments.get("output_format") == "json": return {"type": "collection", "collection": collection} title = collection.get("title", collection.get("id", collection_id)) result_text = f"**Collection: {title}**\n\n" identifier = collection.get("id", collection_id) result_text += f"ID: `{identifier}`\n" description = collection.get("description", "No description available") result_text += f"Description: {description}\n" license_value = collection.get("license", "unspecified") result_text += f"License: {license_value}\n\n" extent = collection.get("extent") or {} if extent: spatial = extent.get("spatial") or {} bbox_list = spatial.get("bbox") or [] if bbox_list: bbox = bbox_list[0] if isinstance(bbox, list | tuple) and len(bbox) >= BBOX_MIN_COORDS: result_text += ( "Spatial Extent: " f"[{bbox[0]:.2f}, {bbox[1]:.2f}, {bbox[2]:.2f}, {bbox[3]:.2f}]\n" ) temporal = extent.get("temporal") or {} interval_list = temporal.get("interval") or [] if interval_list: interval = interval_list[0] start = interval[0] if len(interval) > 0 else "unknown" end = interval[1] if len(interval) > 1 else "present" result_text += f"Temporal Extent: {start} to {end or 'present'}\n" providers = collection.get("providers") or [] if providers: result_text += f"\nProviders: {len(providers)}\n" for provider in providers: name = provider.get("name", "Unknown") roles = provider.get("roles", []) result_text += f" - {name} ({roles})\n" return [TextContent(type="text", text=result_text)]
  • FastMCP @app.tool decorator registration for the 'get_collection' tool, defining input parameters and delegating to the execution module.
    @app.tool async def get_collection( collection_id: str, catalog_url: str | None = None ) -> list[dict[str, Any]]: """Fetch a single STAC Collection by id.""" return await execution.execute_tool( "get_collection", arguments={"collection_id": collection_id}, catalog_url=catalog_url, headers=None, )
  • Internal registry in execution.py mapping tool name 'get_collection' to its handler function.
    _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, }
  • STACClient.get_collection helper method that retrieves and normalizes the raw STAC collection data from the underlying pystac_client.
    def get_collection(self, collection_id: str) -> dict[str, Any]: try: collection = self.client.get_collection(collection_id) except APIError: # pragma: no cover - network dependent logger.exception("Error fetching collection %s", collection_id) raise else: if collection is None: return None return { "id": collection.id, "title": collection.title or collection.id, "description": collection.description, "extent": collection.extent.to_dict() if collection.extent else None, "license": collection.license, "providers": ( [p.to_dict() for p in collection.providers] if collection.providers else [] ), "summaries": ( collection.summaries.to_dict() if collection.summaries else {} ), "assets": ( {k: v.to_dict() for k, v in collection.assets.items()} if collection.assets else {} ), }

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