list-issues
Retrieve and filter GitHub repository issues by status, labels, sort order, and date range to track and manage project tasks effectively.
Instructions
List and filter repository issues
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | No | ||
| labels | No | ||
| owner | Yes | ||
| page | No | ||
| per_page | No | ||
| repo | Yes | ||
| since | No | ||
| sort | No | ||
| state | No |
Implementation Reference
- src/tools/issues.ts:15-73 (handler)The main handler function that executes the list-issues tool logic, parsing input, calling GitHub API, and formatting the response.export async function listIssues(args: unknown): Promise<any> { const { owner, repo, state, labels, sort, direction, since, page, per_page } = ListIssuesSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().issues.listForRepo({ owner, repo, state, labels: labels?.join(','), sort, direction, since, page, per_page, }); return data.map((issue) => ({ id: issue.id, number: issue.number, title: issue.title, state: issue.state, locked: issue.locked, assignees: issue.assignees?.map((assignee) => ({ login: assignee.login, id: assignee.id, type: assignee.type, })), user: issue.user ? { login: issue.user.login, id: issue.user.id, type: issue.user.type, } : null, labels: issue.labels?.map((label) => typeof label === 'string' ? label : { name: label.name, color: label.color, description: label.description, } ), milestone: issue.milestone ? { id: issue.milestone.id, number: issue.milestone.number, title: issue.milestone.title, description: issue.milestone.description, state: issue.milestone.state, } : null, comments: issue.comments, created_at: issue.created_at, updated_at: issue.updated_at, closed_at: issue.closed_at, body: issue.body, url: issue.html_url, pull_request: issue.pull_request ? { url: issue.pull_request.html_url, } : null, })); }, 'Failed to list issues'); }
- src/server.ts:1209-1211 (registration)Registration in the tool dispatch switch statement within the CallToolRequestHandler.case 'list-issues': result = await listIssues(parsedArgs); break;
- src/utils/validation.ts:77-85 (schema)Zod schema for input validation used in the listIssues handler.export const ListIssuesSchema = OwnerRepoSchema.extend({ state: z.enum(['open', 'closed', 'all']).optional(), labels: z.array(z.string()).optional(), sort: z.enum(['created', 'updated', 'comments']).optional(), direction: z.enum(['asc', 'desc']).optional(), since: z.string().optional(), page: z.number().optional(), per_page: z.number().optional(), });
- src/server.ts:523-564 (registration)Tool registration in the ListTools response, including name, description, and input schema.name: 'list-issues', description: 'List and filter repository issues', inputSchema: { type: 'object', properties: { owner: { type: 'string', }, repo: { type: 'string', }, state: { type: 'string', enum: ['open', 'closed', 'all'], }, labels: { type: 'array', items: { type: 'string', }, }, sort: { type: 'string', enum: ['created', 'updated', 'comments'], }, direction: { type: 'string', enum: ['asc', 'desc'], }, since: { type: 'string', }, page: { type: 'number', }, per_page: { type: 'number', }, }, required: ['owner', 'repo'], additionalProperties: false, },
- src/server.ts:33-40 (helper)Import statement bringing in the listIssues handler function.import { listIssues, getIssue, createIssue, updateIssue, addIssueComment, searchIssues as searchIssuesAndPRs, } from './tools/issues.js';