apply_rounding
Rounds worked and overtime minutes, preserving the exact-minute baseline for provably neutral compliance comparisons.
Instructions
Produce a rounded view of a resolved day's worked & overtime minutes without losing the exact-minute result. Useful for the California-style 'exact-minute is the baseline; rounding must be provably neutral' pattern — keep both views and compare across populations.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | ||
| rounding | Yes |
Implementation Reference
- src/tools/apply-rounding.ts:14-20 (handler)The async handler for the 'apply_rounding' tool. It calls resolveDay(input) to get an exact DayResult, then applyRounding(exact, rounding) to produce a rounded view, returning both as JSON.
async ({ input, rounding }) => { const exact = resolveDay(input); const rounded = applyRounding(exact, rounding); return { content: [jsonText({ exact, rounded })] }; }, ); } - src/schemas.ts:88-94 (schema)Zod schema for the 'rounding' parameter: unit (minutes, integer >=1), mode (nearest/up/down, optional, defaults to nearest), and applyTo (array of field names to round, optional).
export const RoundingOptionsSchema = z.object({ unit: z.number().int().min(1), mode: z.enum(['nearest', 'up', 'down']).optional(), applyTo: z .array(z.enum(['workedMinutes', 'otMinutes', 'lateByMinutes', 'earlyOutMinutes', 'breaksDeducted'])) .optional(), }); - src/tools/apply-rounding.ts:6-20 (registration)Registers the tool named 'apply_rounding' on the MCP server with its description, input schema, and rounding options schema.
export function registerApplyRounding(server: McpServer): void { server.tool( 'apply_rounding', "Produce a rounded view of a resolved day's worked & overtime minutes without losing the exact-minute result. Useful for the California-style 'exact-minute is the baseline; rounding must be provably neutral' pattern — keep both views and compare across populations.", { input: ResolveDayInputSchema, rounding: RoundingOptionsSchema, }, async ({ input, rounding }) => { const exact = resolveDay(input); const rounded = applyRounding(exact, rounding); return { content: [jsonText({ exact, rounded })] }; }, ); } - src/server.ts:39-39 (registration)Calls registerApplyRounding(server) to wire the tool into the server during startup.
registerApplyRounding(server); - src/util.ts:7-9 (helper)Helper jsonText function used by the handler to serialize the response as pretty-printed JSON wrapped in an MCP text content block.
export function jsonText(value: unknown): { type: 'text'; text: string } { return { type: 'text', text: JSON.stringify(value, null, 2) }; }