Skip to main content
Glama

get_earthquake_news

Fetch earthquake news for specific locations and date ranges to monitor seismic activity and stay informed about recent events.

Instructions

Fetch earthquake news for a given location within a specified date range.

Args:
    location: Name or identifier of the place where the earthquake(s) occurred.
    date_start: The earliest timestamp in the form of <YYYY-MM-DD HH:mm:ss> (inclusive) to start searching for earthquake news. If omitted, defaults to the current date.
    date_end: The latest timestamp in the form of <YYYY-MM-DD HH:mm:ss> (inclusive) to stop searching for earthquake news. If omitted, defaults to the current date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYes
datetime_startNo
datetime_endNo

Implementation Reference

  • The core handler function decorated with @mcp.tool() for registration. It handles input validation, makes API request to fetch earthquake data, and formats output using helpers.
    @mcp.tool()
    async def get_earthquake_news(location: str, datetime_start: str = None, datetime_end: str = None) -> str:
        """Fetch earthquake news for a given location within a specified date range.
    
        Args:
            location: Name or identifier of the place where the earthquake(s) occurred.
            date_start: The earliest timestamp in the form of <YYYY-MM-DD HH:mm:ss> (inclusive) to start searching for earthquake news. If omitted, defaults to the current date.
            date_end: The latest timestamp in the form of <YYYY-MM-DD HH:mm:ss> (inclusive) to stop searching for earthquake news. If omitted, defaults to the current date.
        """
        if not datetime_start:
            datetime_start = current_date() + " 00:00:01"
        elif not validate_datetime(datetime_start):
            return "Wrong `datetime_start` format given. Accepted format is 'YYYY-MM-DD HH:mm:ss'."
    
        if not datetime_end:
            datetime_end = current_date() + " 23:59:59"
        elif not validate_datetime(datetime_end):
            return "Wrong `datetime_end` format given. Accepted format is 'YYYY-MM-DD HH:mm:ss'."
    
        earthquake_url = f"{GOV_API_BASE}/weather/warning/earthquake"
        data = await make_api_request(earthquake_url, {
                                        "meta": "true",
                                        "sort": "-utcdatetime",
                                        "timestamp_start": f"{datetime_start}@utcdatetime",
                                        "timestamp_end": f"{datetime_end}@utcdatetime",
                                        "icontains": f"{location}@location"
                                    })
    
        if not data or "data" not in data:
            return "Unable to fetch earthquake news or no earthquake news found."
    
        if not data["data"]:
            return "No active earthquake news for this location."
    
        earthquakes = [format_earthquake_data(earthquake_desc) for earthquake_desc in data["data"]]
        return "\n---\n".join(earthquakes)
  • Supporting function that formats individual earthquake data records into human-readable strings, called by the handler.
    def format_earthquake_data(earthquake_res: dict) -> str:
        """Format an earthquake news into a readable string."""
        return f"""
    UTC Datetime: {earthquake_res.get('utcdatetime', 'Unknown')}
    Local Datetime: {earthquake_res.get('localdatetime', 'Unknown')}
    Latitude: {earthquake_res.get('lat', 'Unknown')}
    Longitude: {earthquake_res.get('lon', 'Unknown')}
    Depth: {earthquake_res.get('depth', 'Unknown')}
    Location: {earthquake_res.get('location', 'Unknown')}
    Default Magnitude: {earthquake_res.get('magdefault', 'Unknown')}
    Default Magnitude Type: {earthquake_res.get('magtypedefault', 'Unknown')}
    Status: {earthquake_res.get('status', 'Unknown')}
    Distance/direction to a Malaysian location: {earthquake_res.get('n_distancemas', 'Unknown')}
    Distance/direction to a non-Malaysian location: {earthquake_res.get('n_distancerest', 'Unknown')}
    """

Tool Definition Quality

Score is being calculated. Check back soon.

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/yting27/weather-my-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server