Skip to main content
Glama
joshuaboys

datetime-mcp

by joshuaboys

datetime.now

Get the current date and time in any IANA timezone to synchronize operations with the host OS clock.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tzNoIANA timezone, e.g. Australia/Perth

Implementation Reference

  • Handler for the datetime.now tool which calls nowPayload.
    async ({ tz }) => {
      const zone = tz || DEFAULT_TZ;
      const payload = nowPayload(zone);
    
      return {
        content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
      };
    }
  • src/server.ts:86-99 (registration)
    Registration of the datetime.now tool.
    server.tool(
      "datetime.now",
      {
        tz: z.string().optional().describe("IANA timezone, e.g. Australia/Perth"),
      },
      async ({ tz }) => {
        const zone = tz || DEFAULT_TZ;
        const payload = nowPayload(zone);
    
        return {
          content: [{ type: "text", text: JSON.stringify(payload, null, 2) }],
        };
      }
    );
  • Helper function that generates the payload for datetime.now.
    function nowPayload(tz: string) {
      const d = new Date(); // <-- comes from the host OS clock
      return {
        tz,
        utcIso: d.toISOString(),
        epochMs: d.getTime(),
        human: formatHuman(d, tz),
      };
    }
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/joshuaboys/datetime-mcp'

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