get_time_and_date
Retrieve the current time, date, day of the week, and timestamp in multiple formats for system monitoring or data synchronization tasks using a Local Utilities MCP Server tool.
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:28-36 (handler)The inline handler function for the get_time_and_date tool, which retrieves time data via helper and returns formatted JSON text content.async () => { const result = getCurrentTimeAndDate(); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
- src/mcp/time.ts:11-22 (helper)Core helper function that calculates and returns the current time, date, day of week, ISO string, 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 specifying the structure of the time and date response object.interface ITimeResponse { time: string; date: string; dayOfWeek: string; iso: string; timestamp: number; }
- src/mcp/time.ts:24-38 (registration)Registration function for the get_time_and_date tool, including the tool name, description, and handler.export function registerTimeTool(server: McpServer) { 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)Call to register the time tool on the main MCP server instance.registerTimeTool(server);