batchGetDateByTimestamp
Convert multiple timestamps to readable dates in batch for efficient data processing.
Instructions
Batch convert the provided list of timestamps to date format, used for processing multiple timestamps
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tsList | Yes |
Implementation Reference
- index.ts:43-52 (handler)Handler that executes the batchGetDateByTimestamp tool by invoking the helper on tsList and formatting the array of date strings as TextContent array for MCP response.execute: async (args) => { let result = batchGetDateByTimestamp(args.tsList); let ct: TextContent[] = result.map(item => ({ type: "text", text: item })) return { content: ct, }; },
- index.ts:40-42 (schema)Zod input schema defining tsList as an array of numbers.parameters: z.object({ tsList: z.array(z.number()), }),
- index.ts:37-53 (registration)Registers the batchGetDateByTimestamp tool with FastMCP, including name, description, input schema, and handler.server.addTool({ name: "batchGetDateByTimestamp", description: "Batch convert the provided list of timestamps to date format, used for processing multiple timestamps", parameters: z.object({ tsList: z.array(z.number()), }), execute: async (args) => { let result = batchGetDateByTimestamp(args.tsList); let ct: TextContent[] = result.map(item => ({ type: "text", text: item })) return { content: ct, }; }, });
- index.ts:75-77 (helper)Helper function implementing the core logic: maps each timestamp to a date string using getDateByTimestamp helper.function batchGetDateByTimestamp(tsList: number[]) { return tsList.map(timestamp => getDateByTimestamp(timestamp)); }
- index.ts:71-73 (helper)Supporting helper function that converts a single timestamp to a locale-formatted date string, used by batchGetDateByTimestamp.function getDateByTimestamp(ts: number) { return new Date(ts).toLocaleString() }