Skip to main content
Glama
andybrandt

MCP Simple Timeserver

Get UTC Time from an NTP Server

get_utc
Read-only

Get accurate UTC time from an NTP server to synchronize systems and applications across different timezones.

Instructions

Returns accurate UTC time from an NTP server. This provides a universal time reference regardless of local timezone.

:param server: NTP server address (default: pool.ntp.org)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverNopool.ntp.org

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'get_utc' MCP tool. It queries the specified NTP server using ntplib, computes the UTC time, formats it, and returns it as a string. Handles NTP exceptions gracefully.
    def get_utc(server: str = DEFAULT_NTP_SERVER) -> str:
        """
        Returns accurate UTC time from an NTP server.
        This provides a universal time reference regardless of local timezone.
        
        :param server: NTP server address (default: pool.ntp.org)
        """
        try:
            ntp_client = ntplib.NTPClient()
            response = ntp_client.request(server, version=3)
            utc_time = datetime.fromtimestamp(response.tx_time, tz=UTC)
            formatted_time = utc_time.strftime("%Y-%m-%d %H:%M:%S")
            return f"Current UTC Time from {server}: {formatted_time}"
        except ntplib.NTPException as e:
            return f"Error getting NTP time: {str(e)}"
  • FastMCP registration of the 'get_utc' tool using the @app.tool decorator, including metadata annotations for title and read-only hint.
    @app.tool(
        annotations = {
            "title": "Get UTC Time from an NTP Server",
            "readOnlyHint": True
        }
    )
  • Identical handler function for the 'get_utc' tool in the web-enabled server variant.
    def get_utc(server: str = DEFAULT_NTP_SERVER) -> str:
        """
        Returns accurate UTC time from an NTP server.
        This provides a universal time reference regardless of local timezone.
        
        :param server: NTP server address (default: pool.ntp.org)
        """
        try:
            ntp_client = ntplib.NTPClient()
            response = ntp_client.request(server, version=3)
            utc_time = datetime.fromtimestamp(response.tx_time, tz=UTC)
            formatted_time = utc_time.strftime("%Y-%m-%d %H:%M:%S")
            return f"Current UTC Time from {server}: {formatted_time}"
        except ntplib.NTPException as e:
            return f"Error getting NTP time: {str(e)}" 
  • FastMCP registration of the 'get_utc' tool in the web server variant.
    @app.tool(
        annotations = {
            "title": "Get UTC Time from an NTP Server",
            "readOnlyHint": True
        }
    )
  • Tool schema definition in the DXT manifest generator for packaging the MCP server.
        "name": "get_utc",
        "description": "Returns accurate UTC time from an NTP server."
    }

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/andybrandt/mcp-simple-timeserver'

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