Skip to main content
Glama
cds-id

MCP Server Boilerplate

by cds-id

timestamp

Generate and format timestamps in ISO, Unix, or readable formats to synchronize events or log data within the MCP Server Boilerplate framework.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoiso

Implementation Reference

  • The handler function for the 'timestamp' tool. It takes an optional 'format' parameter (iso, unix, readable) and returns the current timestamp in the specified format as a text content block.
    async ({ format }) => { const now = new Date(); let formattedTime: string; switch (format) { case 'unix': formattedTime = Math.floor(now.getTime() / 1000).toString(); break; case 'readable': formattedTime = now.toLocaleString(); break; case 'iso': default: formattedTime = now.toISOString(); break; } return { content: [ { type: 'text', text: `Current timestamp (${format}): ${formattedTime}`, }, ], }; }
  • The input schema for the 'timestamp' tool using Zod, defining an optional 'format' parameter defaulting to 'iso'.
    { format: z.enum(['iso', 'unix', 'readable']).optional().default('iso'), },
  • The registration function that calls server.tool to register the 'timestamp' tool with its schema and handler.
    export function timestampTool(server: McpServer): void { server.tool( 'timestamp', { format: z.enum(['iso', 'unix', 'readable']).optional().default('iso'), }, async ({ format }) => { const now = new Date(); let formattedTime: string; switch (format) { case 'unix': formattedTime = Math.floor(now.getTime() / 1000).toString(); break; case 'readable': formattedTime = now.toLocaleString(); break; case 'iso': default: formattedTime = now.toISOString(); break; } return { content: [ { type: 'text', text: `Current timestamp (${format}): ${formattedTime}`, }, ], }; } ); }
  • Call to register the timestamp tool within the tools index, which is invoked by the main server.
    // Register timestamp tool timestampTool(server);
  • src/index.ts:34-34 (registration)
    Invocation of registerTools in the main server creation, which chains to timestamp tool registration.
    registerTools(server);

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/cds-id/mcp-server-boilerplate'

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