resolve_period
Resolve a group of duty days into per-day attendance records and optionally a period summary with attendance rate and flags.
Instructions
Resolve a sequence of duty days (a week, a pay period, a month). Returns per-day DayResult entries; optionally include an aggregated PeriodSummary with attendance rate and flag counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | Yes | Inputs for each duty day in the period. | |
| summary | No | Include the aggregated PeriodSummary. Default: true. |
Implementation Reference
- src/tools/resolve-period.ts:7-23 (handler)The registerResolvePeriod function registers the 'resolve_period' tool with the MCP server. The handler calls resolveRange(days) from @attendance-engine/core to process each day, then optionally calls summarize() to include an aggregated PeriodSummary. Returns the payload as JSON text via the jsonText helper.
export function registerResolvePeriod(server: McpServer): void { server.tool( 'resolve_period', "Resolve a sequence of duty days (a week, a pay period, a month). Returns per-day DayResult entries; optionally include an aggregated PeriodSummary with attendance rate and flag counts.", { days: z.array(ResolveDayInputSchema).describe('Inputs for each duty day in the period.'), summary: z.boolean().optional().describe('Include the aggregated PeriodSummary. Default: true.'), }, async ({ days, summary }) => { const results = resolveRange(days); const payload = summary === false ? { days: results } : { days: results, summary: summarize(results) }; return { content: [jsonText(payload)] }; }, ); } - src/schemas.ts:59-70 (schema)ResolveDayInputSchema defines the input schema for each day in the period: date, punches, shift, policy, leave, holiday, weekend. This is used as the array element type for the 'days' parameter of resolve_period.
export const ResolveDayInputSchema = z.object({ date: z .string() .regex(/^\d{4}-\d{2}-\d{2}$/) .describe('Duty date in worksite local wall-clock, YYYY-MM-DD.'), punches: z.array(PunchSchema), shift: ShiftConfigSchema, policy: AttendancePolicySchema.optional(), leave: LeaveDaySchema.nullable().optional(), holiday: z.boolean().optional(), weekend: z.boolean().optional(), }); - src/server.ts:36-37 (registration)The tool is registered via registerResolvePeriod(server) call in the createServer function, after the import on line 11.
registerResolveDay(server); registerResolvePeriod(server); - src/util.ts:7-9 (helper)The jsonText helper serializes a value as pretty-printed JSON and wraps it as an MCP text-content block, used by the resolve_period handler to return its response.
export function jsonText(value: unknown): { type: 'text'; text: string } { return { type: 'text', text: JSON.stringify(value, null, 2) }; }