generate_roster
Generate a rotating roster using built-in patterns (2-2-3, 4-on-4-off, dupont, pitman) or a custom day cycle. Returns shift assignment per date with label and HH:MM window, null on rest days.
Instructions
Generate a rotating roster from a built-in pattern ('2-2-3', '4-on-4-off', 'dupont', 'pitman') or a custom day cycle. Returns one assignment per calendar date with shift label and HH:MM window, or null on rest days.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pattern | Yes | ||
| startDate | Yes | ||
| days | Yes |
Implementation Reference
- src/tools/generate-roster.ts:7-21 (handler)The handler function that registers and implements the 'generate_roster' MCP tool. It accepts a pattern (built-in or custom), a start date, and a number of days, calls the core engine's generateRoster function, and returns the result as JSON text.
export function registerGenerateRoster(server: McpServer): void { server.tool( 'generate_roster', "Generate a rotating roster from a built-in pattern ('2-2-3', '4-on-4-off', 'dupont', 'pitman') or a custom day cycle. Returns one assignment per calendar date with shift label and HH:MM window, or null on rest days.", { pattern: RosterPatternSchema, startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), days: z.number().int().min(0), }, async ({ pattern, startDate, days }) => { const roster = generateRoster(pattern, startDate, days); return { content: [jsonText(roster)] }; }, ); } - src/schemas.ts:72-86 (schema)The RosterPatternSchema validates the 'pattern' input. It accepts either a built-in pattern name ('2-2-3', '4-on-4-off', 'dupont', 'pitman') or a custom array of 'off' literals and shift objects (with label, start, end).
export const RosterPatternSchema = z.union([ z.enum(['2-2-3', '4-on-4-off', 'dupont', 'pitman']), z.object({ custom: z.array( z.union([ z.literal('off'), z.object({ label: z.string(), start: z.string().regex(/^\d{2}:\d{2}$/), end: z.string().regex(/^\d{2}:\d{2}$/), }), ]), ), }), ]); - src/server.ts:40-43 (registration)Registration of the generate_roster tool on the MCP server at line 40: registerGenerateRoster(server);
registerGenerateRoster(server); registerListRulePacks(server); registerAuditPeriodCompliance(server); registerDiagnosePunches(server); - src/util.ts:7-9 (helper)The jsonText helper used by the handler to serialize the roster result as a JSON text content block for MCP response.
export function jsonText(value: unknown): { type: 'text'; text: string } { return { type: 'text', text: JSON.stringify(value, null, 2) }; } - src/resources/docs.ts:16-28 (helper)Documentation entry referencing generate_roster tool as part of the MCP server overview.
- **generate_roster** — rotating-roster generation (2-2-3, 4-on-4-off, dupont, pitman, custom) - **list_rule_packs** — discover available jurisdictions Time-zone rule: every ISO timestamp must carry an explicit offset. The engine never reads the host timezone. DST days work because offsets are explicit. Source: https://github.com/arifur9993/attendance-engine `; const API_MARKDOWN = `# attendance-engine — quick API reference ## resolve_day(input)