get_sprints
Fetch all sprints for a Jira board, with optional filtering by state to show active, closed, or future sprints.
Instructions
Get all sprints for a specific board. Returns sprint information including ID, name, state, and dates.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| boardId | Yes | The ID of the board to get sprints from. Use get_agile_boards to find available board IDs. | |
| state | No | Filter sprints by state: "active" for current sprint, "closed" for completed sprints, "future" for upcoming sprints. |
Implementation Reference
- src/tools/sprints.ts:191-213 (handler)The handler function that executes the get_sprints tool logic. Validates args with getSprintsSchema, calls jiraClient.getSprints(), extracts essential fields (id, name, state, startDate, endDate, goal) from the response, and returns them as JSON.
case 'get_sprints': { const validatedArgs = await getSprintsSchema.validate(args); const sprints = await jiraClient.getSprints(validatedArgs); // Extract only essential fields to reduce token usage const essentialSprints = sprints.values?.map((sprint) => ({ id: sprint.id, name: sprint.name, state: sprint.state, startDate: sprint.startDate, endDate: sprint.endDate, goal: sprint.goal })) || []; return { content: [ { type: 'text', text: JSON.stringify(essentialSprints, null, 2), }, ], }; } - src/schemas/index.ts:196-199 (schema)Yup validation schema for get_sprints. Requires boardId (number), optional state string filtered to one of 'active', 'closed', 'future'.
export const getSprintsSchema = yup.object({ boardId: yup.number().required('Board ID is required'), state: yup.string().oneOf(['active', 'closed', 'future']).optional(), }); - src/schemas/index.ts:257-257 (schema)TypeScript type GetSprintsInput derived from the getSprintsSchema.
export type GetSprintsInput = yup.InferType<typeof getSprintsSchema>; - src/tools/sprints.ts:13-33 (registration)Registration of the get_sprints tool definition including name, description, and inputSchema (boardId required, state optional). The tool is created in createSprintTools() and registered in index.ts via tool listing (line 57) and routing (line 97).
export function createSprintTools(_jiraClient: JiraClient): Tool[] { return [ { name: 'get_sprints', description: 'Get all sprints for a specific board. Returns sprint information including ID, name, state, and dates.', inputSchema: { type: 'object', properties: { boardId: { type: 'number', description: 'The ID of the board to get sprints from. Use get_agile_boards to find available board IDs.', }, state: { type: 'string', enum: ['active', 'closed', 'future'], description: 'Filter sprints by state: "active" for current sprint, "closed" for completed sprints, "future" for upcoming sprints.', }, }, required: ['boardId'], }, }, - src/jira-client.ts:454-464 (helper)The JiraClient.getSprints() method that calls the Jira Agile API (this.agileClient.board.getAllSprints) with boardId and optional state filter.
async getSprints(input: GetSprintsInput) { try { const response = await this.agileClient.board.getAllSprints({ boardId: input.boardId, state: input.state as 'active' | 'closed' | 'future', }); return response; } catch (error) { throw new Error(`Failed to get sprints: ${error instanceof Error ? error.message : 'Unknown error'}`); } }