get-active-iterations
Retrieve active Shortcut iterations for the current user and their team memberships, enabling streamlined project tracking and management via the Shortcut MCP Server.
Instructions
Get the active 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:190-229 (handler)Handler function for the get-active-iterations tool (named 'iterations-get-active'). Fetches active iterations for a specific team or all teams the current user is a member of using the Shortcut client API.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:93-100 (registration)Registration of the 'iterations-get-active' tool, including input schema (teamId optional) and reference to the getActiveIterations handler.server.addToolWithReadAccess( "iterations-get-active", "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:96-98 (schema)Input schema for the 'iterations-get-active' tool: optional teamId as string.{ teamId: z.string().optional().describe("The ID of a team to filter iterations by"), },