Skip to content

Port: lazy STAC re-fetch on cache miss (get_dataset) #8

@boettiger-lab-llm-agent

Description

@boettiger-lab-llm-agent

Summary

mcp-data-server added lazy re-fetch of the STAC catalog when get_dataset gets a cache miss in ae55ab6. This fixes stale registries when new datasets are added to STAC after pod startup.

Changes needed

In stac.py, _stac_get (or get_dataset) should:

  1. Try exact match in STAC_DATASETS
  2. Try fuzzy match
  3. On miss: re-fetch the full catalog once and retry
  4. Return "not found" only after the retry also fails
# ae55ab6 pattern from mcp-data-server stac.py
def get_dataset(dataset_id, ...):
    result = _lookup(dataset_id, STAC_DATASETS)
    if result:
        return result
    # Cache miss — re-fetch catalog and retry once
    fresh = fetch_stac_catalog(...)
    STAC_DATASETS.update(fresh)
    return _lookup(dataset_id, STAC_DATASETS) or f"Dataset '{dataset_id}' not found."

This avoids background threads or periodic refresh while still handling the common case of a newly added dataset.

Reference

mcp-data-server stac.py ae55ab6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions