get_website_status
Check if a website is currently accessible by verifying its operational status through a domain request. This tool determines whether a site is up or down for users.
Instructions
Check the status of a website.
This function takes a root domain as input and checks whether the website is up or down
by making a request to isitdownrightnow.com
Args:
root_domain (str): The root domain of the website to check.
Returns:
str: A message indicating whether the website is up or down, or if the status could not be determined.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| root_domain | Yes |
Implementation Reference
- src/mcp_server_isitdown/server.py:57-95 (handler)The main handler function for the 'get_website_status' tool. It uses httpx to fetch status from isitdownrightnow.com, parses with BeautifulSoup, determines up/down status, extracts last down time using helpers, and returns a status message.@mcp.tool() async def get_website_status(root_domain: str) -> str: """ Check the status of a website. This function takes a root domain as input and checks whether the website is up or down by making a request to isitdownrightnow.com Args: root_domain (str): The root domain of the website to check. Returns: str: A message indicating whether the website is up or down, or if the status could not be determined. """ last_down_time = "Could not determine information about the last down time." try: async with httpx.AsyncClient() as client: response = await client.get( f"{ISITDOWN_BASE_URL}{root_domain}", headers={"User-Agent": USER_AGENT}, timeout=10.0, ) response.raise_for_status() except httpx.HTTPError: return "Could not determine the status of the website." soup = bs(response.text, "html.parser") is_up = soup.find("span", class_="upicon") is_down = soup.find("span", class_="downicon") tabletrsimple_divs = soup.find_all("div", class_="tabletrsimple") if len(tabletrsimple_divs) >= 2: last_down_row = tabletrsimple_divs[ 1 ] # NOTE: Brittle - makes assumptions about HTML structure if isinstance(last_down_row, Tag): last_down_time = get_last_down(last_down_row) return get_response_msg(bool(is_down), bool(is_up), last_down_time)
- Helper function to parse and extract the last down time from the 'isitdownrightnow.com' HTML table row.def get_last_down(last_down_row: Tag) -> str: """ Extract the last down time from the HTML row. Args: last_down_row (bs4.Tag): The HTML row containing the last checked time. Returns: str: The last time the server found the website to be down. """ last_down_time = last_down_row.find_next("span", class_="tab") if last_down_time is None: return "Last down time not found." else: return f"Last down time is: {last_down_time.text.strip()}"
- Helper function to format the final response message based on the detected status (up/down) and last down time.def get_response_msg(is_down: bool, is_up: bool, last_down_time: str) -> str: """ Format the response message based on website status. Args: is_down (bool): Whether the website is down. is_up (bool): Whether the website is up. last_down_time (str): The last time the website was down. Returns: str: Formatted status message. """ if is_down: return f"The website is down. {last_down_time}" elif is_up: return f"The website is up. {last_down_time}" else: return "Could not determine the status of the website."