get-upcoming-iterations
Retrieve upcoming Shortcut iterations for the current user's teams to plan and track project timelines effectively.
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:214-253 (handler)The handler function that executes the tool logic: fetches upcoming iterations for a specific team or all teams associated with the current user using the Shortcut client, formats the response with entity details.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:89-96 (registration)Registers the get-upcoming-iterations tool with the MCP server, providing description, input schema, and linking to the handler method.server.tool( "get-upcoming-iterations", "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:92-94 (schema)Zod input schema defining the optional 'teamId' parameter for filtering iterations by team.{ teamId: z.string().optional().describe("The ID of a team to filter iterations by"), },