get_datasets
Retrieve Earth science datasets from NASA's CMR using specific keywords, date ranges, and DAAC filters to streamline data discovery and access.
Instructions
Get a list of datasets form CMR based on keywords.
Args:
startdate: (Optional) Start date of search request (like "2002" or "2022-03-22")
stopdate: (Optional) Stop date of search request (like "2002" or "2022-03-22")
daac: the daac to search, e.g. NSIDC or PODAAC
keywords: A list of keyword arguments to search collections for.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| daac | No | ||
| keyword | No | ||
| startdate | No | ||
| stopdate | No |
Implementation Reference
- cmr-search.py:47-59 (handler)Core execution logic of the get_datasets tool: constructs search arguments from inputs, performs dataset search using earthaccess, logs count, and joins formatted dataset strings with separators.args = {} if keyword is not None: args['keyword'] = keyword if daac is not None: args['daac'] = daac if startdate is not None or stopdate is not None: args['temporal'] = (startdate, stopdate) collections = earthaccess.search_datasets(count=5, **args ) logger.debug(len(collections)) #alerts = [format_dataset(feature) for feature in data["features"]] return "\n---\n".join([format_dataset(ds) for ds in collections])
- cmr-search.py:34-46 (schema)Input schema defined by function parameters with types and default values, plus comprehensive docstring describing arguments and usage.async def get_datasets( startdate: str = None, stopdate: str = None, daac: Optional[str] = None, keyword: str= None) -> str: """Get a list of datasets form CMR based on keywords. Args: startdate: (Optional) Start date of search request (like "2002" or "2022-03-22") stopdate: (Optional) Stop date of search request (like "2002" or "2022-03-22") daac: the daac to search, e.g. NSIDC or PODAAC keywords: A list of keyword arguments to search collections for. """
- cmr-search.py:33-33 (registration)Registers the get_datasets function as an MCP tool using the FastMCP decorator.@mcp.tool()
- cmr-search.py:14-30 (helper)Supporting function to format a single dataset (feature) into a human-readable string, handling errors gracefully.def format_dataset(feature: dict) -> str: """Format an alert feature into a readable string.""" props = feature logger.debug(props.concept_id()) try: return f""" ConceptID: {props.concept_id()} Description: {props.abstract()} Shortname: {props.summary()['short-name']} """ except Exception as e: logging.error(traceback.format_exc()) #Currently an error in earthaccess that relies on `FileDistributionInformation` to exist will be caught here from the 'summary()' method. # Returning empty string. return ""