getTodayDate
Retrieve today's date in YYYY-MM-DD format according to the local timezone. Avoid hardcoding dates by using this tool for accurate and dynamic date retrieval.
Instructions
Get today's date in local timezone (YYYY-MM-DD format). Use this tool whenever you need today's date - NEVER hardcode dates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| random_string | No | Dummy parameter for no-parameter tools |
Implementation Reference
- dist/index.js:170-184 (handler)The asynchronous handler function that computes today's date using new Date(), formats it to YYYY-MM-DD, and returns it as text content.}, async () => { const today = new Date(); const year = today.getFullYear(); const month = String(today.getMonth() + 1).padStart(2, '0'); const day = String(today.getDate()).padStart(2, '0'); const todayDate = `${year}-${month}-${day}`; return { content: [ { type: "text", text: todayDate } ] }; });
- dist/index.js:167-169 (schema)Zod schema for input parameters: an optional dummy string to allow no-parameter tool calls.random_string: z.string() .optional() .describe("Dummy parameter for no-parameter tools")
- dist/index.js:166-184 (registration)Full registration of the getTodayDate tool using server.tool(), including description, schema, and inline handler function.server.tool("getTodayDate", "Get today's date in local timezone (YYYY-MM-DD format). Use this tool whenever you need today's date - NEVER hardcode dates.", { random_string: z.string() .optional() .describe("Dummy parameter for no-parameter tools") }, async () => { const today = new Date(); const year = today.getFullYear(); const month = String(today.getMonth() + 1).padStart(2, '0'); const day = String(today.getDate()).padStart(2, '0'); const todayDate = `${year}-${month}-${day}`; return { content: [ { type: "text", text: todayDate } ] }; });