get_time_and_date
Returns the current local time, date, day of week, and timestamp in multiple formats for system time access.
Instructions
Returns the current time, date, day of week, and timestamp in various formats
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/time.ts:24-38 (registration)Registration of the 'get_time_and_date' tool via server.tool() with a description and async 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/mcp/time.ts:11-22 (handler)Core handler function getCurrentTimeAndDate() that creates a Date object and returns time, date, dayOfWeek, ISO string, and 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)ITimeResponse interface defining the shape of the tool's output (time, date, dayOfWeek, iso, timestamp).
interface ITimeResponse { time: string; date: string; dayOfWeek: string; iso: string; timestamp: number; } - src/index.ts:9-9 (registration)Import of registerTimeTool in the main entry point.
import { registerTimeTool } from "./mcp/time.js"; - src/index.ts:24-24 (registration)Call to registerTimeTool(server) that wires the tool into the MCP server.
registerTimeTool(server);