get_current_iteration
Retrieve the currently active iteration for a GitHub project based on today's date to track sprint progress and manage workflows.
Instructions
Get the currently active iteration based on today's date
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ||
| fieldName | No |
Implementation Reference
- Core implementation of get_current_iteration tool. Computes the currently active iteration by checking which iteration's date range (from project iteration field configuration) contains the current date.async getCurrentIteration(data: { projectId: string; fieldName?: string; }): Promise<{ id: string; title: string; startDate: string; endDate: string; duration: number; } | null> { try { const config = await this.getIterationConfiguration(data); const now = new Date(); for (const iteration of config.iterations) { const start = new Date(iteration.startDate); const end = new Date(start); end.setDate(end.getDate() + iteration.duration); if (now >= start && now < end) { return { id: iteration.id, title: iteration.title, startDate: iteration.startDate, endDate: end.toISOString(), duration: iteration.duration }; } } return null; } catch (error) { throw this.mapErrorToMCPError(error); } }
- Tool definition for get_current_iteration, including name, description, input schema reference, and usage examples.export const getCurrentIterationTool: ToolDefinition<GetCurrentIterationArgs> = { name: "get_current_iteration", description: "Get the currently active iteration based on today's date", schema: getCurrentIterationSchema as unknown as ToolSchema<GetCurrentIterationArgs>, examples: [ { name: "Get current sprint", description: "Find which iteration is currently active", args: { projectId: "PVT_kwDOLhQ7gc4AOEbH" } } ] };
- Zod input schema definition for validating get_current_iteration tool arguments.export const getCurrentIterationSchema = z.object({ projectId: z.string().min(1, "Project ID is required"), fieldName: z.string().optional() }); export type GetCurrentIterationArgs = z.infer<typeof getCurrentIterationSchema>;
- src/infrastructure/tools/ToolRegistry.ts:288-292 (registration)Registration of the getCurrentIterationTool in the central ToolRegistry singleton.this.registerTool(getIterationConfigurationTool); this.registerTool(getCurrentIterationTool); this.registerTool(getIterationItemsTool); this.registerTool(getIterationByDateTool); this.registerTool(assignItemsToIterationTool);
- src/index.ts:491-492 (handler)MCP tool request router that dispatches get_current_iteration calls to ProjectManagementService.getCurrentIteration method.case "get_current_iteration": return await this.service.getCurrentIteration(args);
- Supporting helper method that retrieves the iteration field configuration (including all iterations) used by getCurrentIteration.async getIterationConfiguration(data: { projectId: string; fieldName?: string; }): Promise<{ fieldId: string; fieldName: string; duration: number; startDay: number; iterations: Array<{ id: string; title: string; startDate: string; duration: number; }>; }> { try { const fields = await this.listProjectFields({ projectId: data.projectId }); // Find iteration field const iterationField = fields.find((f: CustomField) => f.type === 'iteration' && (!data.fieldName || f.name === data.fieldName) ); if (!iterationField) { throw new ResourceNotFoundError( ResourceType.FIELD, data.fieldName || 'iteration field' ); } if (!iterationField.config) { throw new Error('Invalid iteration field configuration'); } return { fieldId: iterationField.id, fieldName: iterationField.name, duration: iterationField.config.iterationDuration || 14, startDay: iterationField.config.iterationStart ? new Date(iterationField.config.iterationStart).getDay() : 1, iterations: (iterationField.config.iterations || []).map((iter: any) => ({ id: iter.id, title: iter.title, startDate: iter.startDate, duration: iter.duration })) }; } catch (error) { throw this.mapErrorToMCPError(error); } }