get-current-timezone
Retrieve the current system timezone to enable accurate datetime handling for AI agents and chat interfaces.
Instructions
Get the current system timezone
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get-current-timezone"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:31-43 (registration)Registers the 'get-current-timezone' tool with the MCP server, including inline handler function that retrieves and returns the current system timezone.
server.tool( "get-current-timezone", "Get the current system timezone", async () => { const timezone = getCurrentTimezone(); return { content: [{ type: "text", text: `The current system timezone is ${timezone}` }] }; } ); - src/server.ts:34-42 (handler)Inline handler function for the tool that calls getCurrentTimezone() and formats the response as text content.
async () => { const timezone = getCurrentTimezone(); return { content: [{ type: "text", text: `The current system timezone is ${timezone}` }] }; } - src/timezone-utils.ts:66-74 (helper)Core helper function that implements the logic to get the current system timezone using Intl.DateTimeFormat().resolvedOptions().timeZone, with fallback to UTC.
export function getCurrentTimezone(): string { try { const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; return processTimezone(timezone); } catch (error) { console.error("Error getting current timezone:", error); return "UTC"; // Default to UTC if there's an error } }