Skip to main content
Glama

search_items

Search for geospatial datasets like satellite imagery and weather data using spatial, temporal, and attribute filters through STAC APIs.

Instructions

Search for STAC items.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionsYes
bboxNo
datetimeNo
limitNo
queryNo
output_formatNotext
catalog_urlNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function that executes the search_items tool logic: searches STAC items via STACClient, formats results as formatted text or JSON.
    def handle_search_items(
        client: STACClient,
        arguments: dict[str, Any],
    ) -> list[TextContent] | dict[str, Any]:
        collections = arguments.get("collections")
        bbox = arguments.get("bbox")
        dt = arguments.get("datetime")
        query = arguments.get("query")
        limit = arguments.get("limit", 10)
        items = client.search_items(
            collections=collections,
            bbox=bbox,
            datetime=dt,
            query=query,
            limit=limit,
        )
        if arguments.get("output_format") == "json":
            return {"type": "item_list", "count": len(items), "items": items}
        result_text = f"Found {len(items)} items:\n\n"
        asset_keys = set()
        for item in items:
            item_id = item.get("id", "unknown")
            collection_id = item.get("collection", "unknown")
            result_text += f"**{item_id}** (Collection: `{collection_id}`)\n"
            dt_value = item.get("datetime")
            if dt_value:
                result_text += f"  Date: {dt_value}\n"
            bbox = item.get("bbox")
            if isinstance(bbox, list | tuple) and len(bbox) >= BBOX_MIN_COORDS:
                result_text += (
                    "  BBox: "
                    f"[{bbox[0]:.2f}, {bbox[1]:.2f}, {bbox[2]:.2f}, {bbox[3]:.2f}]\n"
                )
            assets = item.get("assets") or {}
            asset_keys.update(assets.keys())
            asset_count = len(assets) if hasattr(assets, "__len__") else 0
            result_text += f"  Assets: {asset_count}\n\n"
            result_text += "\n"
        if asset_keys:
            result_text += "Assets found across items:\n"
            for key in sorted(asset_keys):
                result_text += f" - {key}\n"
        return [TextContent(type="text", text=result_text)]
  • MCP tool registration using @app.tool decorator, defines input parameters (schema) and dispatches to execution engine.
    @app.tool
    async def search_items(
        collections: list[str] | str,
        bbox: list[float] | str | None = None,
        datetime: str | None = None,
        limit: int | None = 10,
        query: dict[str, Any] | str | None = None,
        output_format: str | None = "text",
        catalog_url: str | None = None,
    ) -> list[dict[str, Any]]:
        """Search for STAC items."""
        arguments = preprocess_parameters(
            {
                "collections": collections,
                "bbox": bbox,
                "datetime": datetime,
                "limit": limit,
                "query": query,
                "output_format": output_format,
            }
        )
        return await execution.execute_tool(
            "search_items",
            arguments=arguments,
            catalog_url=catalog_url,
            headers=None,
        )
  • Internal registry mapping 'search_items' tool name to its handler function for dispatch in 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,
    }
  • Helper function to preprocess input parameters (e.g., parse stringified JSON for bbox, collections, query), used by search_items registration.
    def preprocess_parameters(arguments: dict[str, Any]) -> dict[str, Any]:
        """Preprocess tool parameters to handle various input formats.
    
        This function normalizes parameters that may come in as strings but should be
        other types (arrays, objects, etc.). This is particularly useful when MCP clients
        serialize parameters as strings.
    
        Args:
            arguments: Raw arguments dictionary from MCP client
    
        Returns:
            Preprocessed arguments with proper types
        """
        if not arguments:
            return arguments
    
        processed = arguments.copy()
    
        # Handle bbox parameter - should be a list of 4 floats
        if "bbox" in processed and processed["bbox"] is not None:
            bbox = processed["bbox"]
            if isinstance(bbox, str):
                try:
                    # Try to parse as JSON
                    parsed = json.loads(bbox)
                    if isinstance(parsed, list) and len(parsed) == 4:  # noqa: PLR2004
                        processed["bbox"] = [float(x) for x in parsed]
                        logger.debug(
                            "Converted bbox from string to list: %s", processed["bbox"]
                        )
                except (json.JSONDecodeError, ValueError, TypeError) as e:
                    logger.warning("Failed to parse bbox string: %s, error: %s", bbox, e)
    
        # Handle collections parameter - should be a list of strings
        if "collections" in processed and processed["collections"] is not None:
            collections = processed["collections"]
            if isinstance(collections, str):
                try:
                    parsed = json.loads(collections)
                    if isinstance(parsed, list):
                        processed["collections"] = parsed
                        logger.debug(
                            "Converted collections from string to list: %s",
                            processed["collections"],
                        )
                except (json.JSONDecodeError, ValueError, TypeError) as e:
                    logger.warning(
                        "Failed to parse collections string: %s, error: %s", collections, e
                    )
    
        # Handle aoi_geojson parameter - should be a dict/object
        if "aoi_geojson" in processed and processed["aoi_geojson"] is not None:
            aoi = processed["aoi_geojson"]
            if isinstance(aoi, str):
                try:
                    parsed = json.loads(aoi)
                    if isinstance(parsed, dict):
                        processed["aoi_geojson"] = parsed
                        logger.debug("Converted aoi_geojson from string to dict")
                except (json.JSONDecodeError, ValueError, TypeError) as e:
                    logger.warning(
                        "Failed to parse aoi_geojson string: %s, error: %s", aoi, e
                    )
    
        # Handle query parameter - should be a dict/object
        if "query" in processed and processed["query"] is not None:
            query = processed["query"]
            if isinstance(query, str):
                try:
                    parsed = json.loads(query)
                    if isinstance(parsed, dict):
                        processed["query"] = parsed
                        logger.debug("Converted query from string to dict")
                except (json.JSONDecodeError, ValueError, TypeError) as e:
                    logger.warning("Failed to parse query string: %s, error: %s", query, e)
    
        if "limit" in processed and processed["limit"] is not None:
            limit = processed["limit"]
            if isinstance(limit, str):
                try:
                    processed["limit"] = int(limit)
                    logger.debug(
                        "Converted limit from string to int: %d", processed["limit"]
                    )
                except ValueError as e:
                    logger.warning(
                        "Failed to convert limit string to int: %s, error: %s", limit, e
                    )
    
        return processed
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. It only states the action ('search for STAC items') without mentioning expected behaviors like pagination (implied by 'limit' parameter), authentication needs, rate limits, or what happens with no results. For a search tool with 7 parameters and no annotation coverage, this is a significant gap.

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 4 words, with no wasted text. It's front-loaded with the core action, though this brevity comes at the cost of completeness. Every word earns its place by stating the essential 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 tool's complexity (7 parameters, 1 required), lack of annotations, and rich input schema, the description is inadequate. While an output schema exists (which reduces the need to describe return values), the description doesn't provide enough context about how to use the tool effectively, what the search entails, or how parameters interact. For a search tool with multiple filtering options, this is insufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides no information about any of the 7 parameters. With 0% schema description coverage, the description fails to compensate by explaining what parameters like 'collections', 'bbox', 'datetime', or 'query' mean or how they affect the search. This leaves the agent with no semantic understanding beyond the raw schema.

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 searches for STAC items, which is a clear verb+resource combination. However, it doesn't differentiate from sibling tools like 'get_item' (which retrieves a specific item) or 'search_collections' (which searches collections rather than items), leaving the purpose somewhat vague in context.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'get_item' for retrieving specific items or 'search_collections' for searching collections, nor does it specify any prerequisites or contextual constraints for usage.

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