get_utc
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
| Name | Required | Description | Default |
|---|---|---|---|
| server | No | pool.ntp.org |
Implementation Reference
- mcp_simple_timeserver/server.py:34-49 (handler)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)}"
- mcp_simple_timeserver/server.py:28-33 (registration)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)}"
- mcp_simple_timeserver/web/server.py:32-37 (registration)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 } )
- dxt/prepare-DXT.py:172-174 (schema)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." }