Skip to main content
Glama
andybrandt

MCP Simple Timeserver

get_utc

Retrieve precise UTC time from an NTP server to ensure a universal time reference, independent of local timezone settings. Simplifies time synchronization.

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

Implementation Reference

  • Core handler function for the 'get_utc' tool. Queries the specified NTP server (default 'pool.ntp.org') to retrieve and format the current UTC time.
    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)}"
  • Handler function for the 'get_utc' tool in the web server variant. Identical logic to the main server implementation.
    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)}"
  • Registration of the 'get_utc' tool using FastMCP's @app.tool decorator, including annotations for title and read-only hint.
    @app.tool( annotations = { "title": "Get UTC Time from an NTP Server", "readOnlyHint": True } )
  • Registration of the 'get_utc' tool in the web server using FastMCP's @app.tool decorator.
    @app.tool( annotations = { "title": "Get UTC Time from an NTP Server", "readOnlyHint": True } )
  • Default NTP server constant used by the get_utc handler.
    DEFAULT_NTP_SERVER = 'pool.ntp.org'

Other Tools

Related 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