get_time_and_date
Retrieve current time, date, day of week, and timestamp in multiple formats for system integration and time-sensitive operations.
Instructions
Returns the current time, date, day of week, and timestamp in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/time.ts:11-22 (handler)Core handler function that retrieves and formats the current time, date, day of week, ISO timestamp, and Unix timestamp.export function getCurrentTimeAndDate(): ITimeResponse { const now = new Date(); const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; return { time: now.toLocaleTimeString(), date: now.toLocaleDateString(), dayOfWeek: days[now.getDay()], iso: now.toISOString(), timestamp: now.getTime(), }; }
- src/mcp/time.ts:3-9 (schema)TypeScript interface defining the shape of the time and date response object.interface ITimeResponse { time: string; date: string; dayOfWeek: string; iso: string; timestamp: number; }
- src/mcp/time.ts:25-37 (registration)Registers the 'get_time_and_date' tool with the MCP server, including description and execution handler.server.tool( "get_time_and_date", "Returns the current time, date, day of week, and timestamp in various formats", async () => { const result = getCurrentTimeAndDate(); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } );
- src/index.ts:24-24 (registration)Calls the module registration function to add the time tool to the main MCP server instance.registerTimeTool(server);
- src/index.ts:9-9 (registration)Imports the registration function for the time tool.import { registerTimeTool } from "./mcp/time.js";