get-active-iterations
Retrieve active Shortcut iterations for the current user's teams to track ongoing project cycles and sprints.
Instructions
Get the active 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:173-212 (handler)The main handler function that executes the tool logic: retrieves active Shortcut iterations for the current user's teams or a specific team using the ShortcutClientWrapper.async getActiveIterations(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.getActiveIteration([teamId]); const iterations = result.get(teamId); if (!iterations?.length) return this.toResult(`Result: No active iterations found for team.`); if (iterations.length === 1) return this.toResult( "The active iteration for the team is:", await this.entityWithRelatedEntities(iterations[0], "iteration"), ); return this.toResult( "The active 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.getActiveIteration(teamIds); const allActiveIterations = [...resultsByTeam.values()].flat(); if (!allActiveIterations.length) return this.toResult("Result: No active iterations found for any of your teams."); return this.toResult( `You have ${allActiveIterations.length} active iterations for your teams:`, await this.entitiesWithRelatedEntities(allActiveIterations, "iterations"), ); }
- src/tools/iterations.ts:80-87 (registration)Registration of the 'get-active-iterations' MCP tool using server.tool(), which includes the schema and references the handler method.server.tool( "get-active-iterations", "Get the active 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.getActiveIterations(teamId), );
- src/tools/iterations.ts:83-85 (schema)Input schema for the tool: optional teamId string to filter iterations by team.{ teamId: z.string().optional().describe("The ID of a team to filter iterations by"), },