iterations-get-upcoming
Retrieve upcoming Shortcut iterations for your team to plan project timelines and track sprint schedules.
Instructions
Get the upcoming Shortcut iterations for the current user based on their team memberships
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| teamId | No | The ID of a team to filter iterations by |
Implementation Reference
- src/tools/iterations.ts:231-270 (handler)Implements the core logic for retrieving upcoming Shortcut iterations, either for a specific team or all teams the current user belongs to, using the ShortcutClientWrapper. Handles errors, formats results, and includes related entities.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"), ); }
- src/tools/iterations.ts:102-109 (registration)Registers the 'iterations-get-upcoming' tool on the MCP server with input schema validation using Zod and links to the handler 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:106-107 (schema)Zod schema for input parameters: optional teamId string.teamId: z.string().optional().describe("The ID of a team to filter iterations by"), },