get_epic_dates
Retrieve available dates for EPIC Earth imagery by specifying the collection type (natural or enhanced) through the NASA-MCP server. Ideal for accessing Earth observation data.
Instructions
Get available dates for EPIC images.
Args: collection: Collection type. Options: natural, enhanced.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| collection | No | natural |
Implementation Reference
- src/nasa_mcp/server.py:1047-1092 (handler)The handler function implementing the 'get_epic_dates' tool. It queries the NASA EPIC API for all images in the specified collection (natural or enhanced) and extracts unique dates from the response.@mcp.tool() async def get_epic_dates(collection: str = "natural") -> str: """Get available dates for EPIC images. Args: collection: Collection type. Options: natural, enhanced. """ if collection not in ["natural", "enhanced"]: return "Invalid collection. Available options: natural, enhanced." url = f"{NASA_API_BASE}/EPIC/api/{collection}/all" data = await make_nasa_request(url) if not data: return f"Could not retrieve available dates for EPIC {collection} collection due to a connection error." # Check for error response (must be a dictionary) if isinstance(data, dict): if "error" in data: return f"API Error: {data.get('error')} - Details: {data.get('details', 'N/A')}" if data.get("binary_content"): return f"Received unexpected binary content from EPIC Dates API. URL: {data.get('url')}" # Ensure data is a list if not isinstance(data, list): logger.error(f"Unexpected non-list response from EPIC Dates API: {data}") return "Received unexpected data format from EPIC Dates API." try: if not data: # Empty list return f"No dates available for EPIC images from the {collection} collection." # Data is a list of objects like {'date': 'YYYY-MM-DD HH:MM:SS'} # Extract unique dates (YYYY-MM-DD part) unique_dates = sorted(list(set(item.get('date', '').split(' ')[0] for item in data if item.get('date')))) result = [f"Available dates for EPIC {collection} images: {len(unique_dates)}"] # Show dates in groups of 10 per line for i in range(0, len(unique_dates), 10): result.append(", ".join(unique_dates[i:i+10])) return "n".join(result) except Exception as e: logger.error(f"Error processing available dates for EPIC images: {str(e)}") return f"Error processing available dates for EPIC images: {str(e)}"