Skip to main content
Glama

get_collection

Retrieve a specific STAC Collection by its unique identifier to access metadata about geospatial datasets like satellite imagery or weather data.

Instructions

Fetch a single STAC Collection by id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collection_idYes
catalog_urlNo

Implementation Reference

  • The core handler function that executes the 'get_collection' tool: fetches the STAC collection by ID using STACClient and formats a textual or JSON response.
    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)]
  • Internal registry in execution.py that maps the tool name 'get_collection' to its handler function handle_get_collection.
    _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, }
  • FastMCP server registration of the 'get_collection' tool, defining input schema via parameters (collection_id: str, catalog_url: str | None) and delegating to execution.execute_tool.
    @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, )
  • Input schema for the tool derived from the registered function signature: requires collection_id (str), optional catalog_url (str). Output is list[dict[str, Any]]. Note: handler supports additional 'output_format' param.
    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, )

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