Skip to main content
Glama

MCP Server Boilerplate

by cds-id
timestampTool.ts998 B
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; /** * A tool that provides the current timestamp in various formats * @param server The MCP server instance */ 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}`, }, ], }; } ); }

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