get-upcoming-iterations
Retrieve upcoming project iterations for the current user based on team memberships. Filter results by team ID to streamline planning and project management.
Instructions
Get the upcoming Shortcut iterations for the current user based on their team memberships
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| teamId | No | The ID of a team to filter iterations by |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"teamId": {
"description": "The ID of a team to filter iterations by",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/iterations.ts:102-109 (registration)Registration of the tool named 'iterations-get-upcoming' (matches 'get-upcoming-iterations' intent) in IterationTools.create method.server.addToolWithReadAccess( "iterations-get-upcoming", "Get the upcoming Shortcut iterations for the current user based on their team memberships", { teamId: z.string().optional().describe("The ID of a team to filter iterations by"), }, async ({ teamId }) => await tools.getUpcomingIterations(teamId), );
- src/tools/iterations.ts:105-107 (schema)Input schema definition using Zod: optional teamId string.{ teamId: z.string().optional().describe("The ID of a team to filter iterations by"), },
- src/tools/iterations.ts:231-270 (handler)The handler function getUpcomingIterations that implements the core logic: fetches upcoming iterations via client.getUpcomingIteration for a team or current user's teams, formats response.async getUpcomingIterations(teamId?: string) { if (teamId) { const team = await this.client.getTeam(teamId); if (!team) throw new Error(`No team found matching id: "${teamId}"`); const result = await this.client.getUpcomingIteration([teamId]); const iterations = result.get(teamId); if (!iterations?.length) return this.toResult(`Result: No upcoming iterations found for team.`); if (iterations.length === 1) return this.toResult( "The next upcoming iteration for the team is:", await this.entityWithRelatedEntities(iterations[0], "iteration"), ); return this.toResult( "The next upcoming iterations for the team are:", await this.entitiesWithRelatedEntities(iterations, "iterations"), ); } const currentUser = await this.client.getCurrentUser(); if (!currentUser) throw new Error("Failed to retrieve current user."); const teams = await this.client.getTeams(); const teamIds = teams .filter((team) => team.member_ids.includes(currentUser.id)) .map((team) => team.id); if (!teamIds.length) throw new Error("Current user does not belong to any teams."); const resultsByTeam = await this.client.getUpcomingIteration(teamIds); const allUpcomingIterations = [...resultsByTeam.values()].flat(); if (!allUpcomingIterations.length) return this.toResult("Result: No upcoming iterations found for any of your teams."); return this.toResult( "The upcoming iterations for all your teams are:", await this.entitiesWithRelatedEntities(allUpcomingIterations, "iterations"), ); }