Skip to main content
Glama
DSado88

DateTime MCP Server

by DSado88

get_current_date

Retrieve the current date in ISO, US, EU, or custom formats to ensure time-sensitive content uses accurate date information.

Instructions

Get only the current date

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format: 'iso' (YYYY-MM-DD), 'us' (MM/DD/YYYY), 'eu' (DD/MM/YYYY), or custom formatiso

Implementation Reference

  • Handler for the 'get_current_date' tool. Extracts the current date from 'now' (a new Date()), formats it based on the 'format' parameter ('iso', 'us', 'eu', or custom via formatDate helper), and returns it as text content.
    case "get_current_date": { const format = request.params.arguments?.format || "iso"; let result: string; if (format === "iso") { result = now.toISOString().split('T')[0]; } else if (format === "us") { result = `${(now.getMonth() + 1).toString().padStart(2, '0')}/${now.getDate().toString().padStart(2, '0')}/${now.getFullYear()}`; } else if (format === "eu") { result = `${now.getDate().toString().padStart(2, '0')}/${(now.getMonth() + 1).toString().padStart(2, '0')}/${now.getFullYear()}`; } else { result = formatDate(now, format as string); } return { content: [{ type: "text", text: result }] }; }
  • src/index.ts:44-57 (registration)
    Tool registration in ListTools handler, defining name, description, and input schema for 'get_current_date'.
    { name: "get_current_date", description: "Get only the current date", inputSchema: { type: "object", properties: { format: { type: "string", description: "Output format: 'iso' (YYYY-MM-DD), 'us' (MM/DD/YYYY), 'eu' (DD/MM/YYYY), or custom format", default: "iso" } } } },
  • Input schema definition for the 'get_current_date' tool, specifying the optional 'format' parameter.
    inputSchema: { type: "object", properties: { format: { type: "string", description: "Output format: 'iso' (YYYY-MM-DD), 'us' (MM/DD/YYYY), 'eu' (DD/MM/YYYY), or custom format", default: "iso" } } }
  • Helper function 'formatDate' used by 'get_current_date' (and others) for custom date formatting with placeholders like YYYY, MM, etc.
    function formatDate(date: Date, format: string): string { const replacements: { [key: string]: string } = { 'YYYY': date.getFullYear().toString(), 'MM': (date.getMonth() + 1).toString().padStart(2, '0'), 'DD': date.getDate().toString().padStart(2, '0'), 'HH': date.getHours().toString().padStart(2, '0'), 'mm': date.getMinutes().toString().padStart(2, '0'), 'ss': date.getSeconds().toString().padStart(2, '0'), }; let result = format; for (const [key, value] of Object.entries(replacements)) { result = result.replace(new RegExp(key, 'g'), value); } return result; }

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/DSado88/datetime-mcp'

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