Skip to main content
Glama
DSado88

DateTime MCP Server

by DSado88

get_current_date

Retrieve the current date in multiple formats ('iso', 'us', 'eu', or custom) using the DateTime MCP Server, ensuring accurate time-sensitive data for Claude models.

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 format from arguments, computes the current date in the specified format (iso, us, eu, or custom via formatDate), 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)
    Registration of the get_current_date tool in the ListTools response, including name, description, and input schema definition.
    { 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" } } } },
  • Helper function formatDate used by get_current_date (and other tools) to format dates according to custom format strings using token replacement.
    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; }

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

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