get_issues
Retrieve and filter issues from Mantis Bug Tracker by project, status, handler, reporter, or keywords. Specify fields like id, summary, and description to optimize query results and avoid errors.
Instructions
獲取 Mantis 問題列表,可根據多個條件進行過濾,建議查詢時select選擇id,summary,description就好,資訊過多可能導致程式異常
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handlerId | No | 處理人 ID | |
| page | No | 分頁起始位置,從1開始 | |
| pageSize | No | 頁數大小 | |
| projectId | No | 專案 ID | |
| reporterId | No | 報告者 ID | |
| search | No | 搜尋關鍵字 | |
| select | No | 選擇要返回的欄位,例如:['id', 'summary', 'description'] | |
| statusId | No | 狀態 ID |
Implementation Reference
- src/server.ts:134-153 (handler)The handler function for the MCP 'get_issues' tool. It checks if Mantis is configured, calls mantisApi.getIssues with the provided params, stringifies the issues, and applies gzip compression if the JSON exceeds 100KB threshold, returning compressed base64 data.async (params) => { return withMantisConfigured("get_issues", async () => { const issues = await mantisApi.getIssues(params); const jsonString = JSON.stringify(issues); if (jsonString.length < COMPRESSION_THRESHOLD) { return jsonString; } const compressed = await gzipAsync(Buffer.from(jsonString)); const base64Data = compressed.toString('base64'); return JSON.stringify({ compressed: true, data: base64Data, originalSize: jsonString.length, compressedSize: base64Data.length }); }); }
- src/server.ts:124-133 (schema)Zod input schema validation for the 'get_issues' tool parameters including projectId, statusId, handlerId, reporterId, search, pagination, and select fields.{ projectId: z.number().optional().describe("專案 ID"), statusId: z.number().optional().describe("狀態 ID"), handlerId: z.number().optional().describe("處理人 ID"), reporterId: z.number().optional().describe("報告者 ID"), search: z.string().optional().describe("搜尋關鍵字"), pageSize: z.number().optional().default(20).describe("頁數大小"), page: z.number().optional().default(0).describe("分頁起始位置,從1開始"), select: z.array(z.string()).optional().describe("選擇要返回的欄位,例如:['id', 'summary', 'description']"), },
- src/server.ts:121-154 (registration)Registration of the 'get_issues' tool on the MCP server, including name, description, input schema, and handler function.server.tool( "get_issues", "獲取 Mantis 問題列表,可根據多個條件進行過濾,建議查詢時select選擇id,summary,description就好,資訊過多可能導致程式異常", { projectId: z.number().optional().describe("專案 ID"), statusId: z.number().optional().describe("狀態 ID"), handlerId: z.number().optional().describe("處理人 ID"), reporterId: z.number().optional().describe("報告者 ID"), search: z.string().optional().describe("搜尋關鍵字"), pageSize: z.number().optional().default(20).describe("頁數大小"), page: z.number().optional().default(0).describe("分頁起始位置,從1開始"), select: z.array(z.string()).optional().describe("選擇要返回的欄位,例如:['id', 'summary', 'description']"), }, async (params) => { return withMantisConfigured("get_issues", async () => { const issues = await mantisApi.getIssues(params); const jsonString = JSON.stringify(issues); if (jsonString.length < COMPRESSION_THRESHOLD) { return jsonString; } const compressed = await gzipAsync(Buffer.from(jsonString)); const base64Data = compressed.toString('base64'); return JSON.stringify({ compressed: true, data: base64Data, originalSize: jsonString.length, compressedSize: base64Data.length }); }); } );
- src/services/mantisApi.ts:213-237 (helper)Helper function mantisApi.getIssues that constructs query parameters, applies caching, and makes HTTP GET request to Mantis API /issues endpoint to retrieve filtered and paginated issues.async getIssues(params: IssueSearchParams = {}): Promise<Issue[]> { log.info('獲取問題列表', { params }); // 構建過濾 URL let filter = ''; if (params.projectId) filter += `&project_id=${params.projectId}`; if (params.statusId) filter += `&status_id=${params.statusId}`; if (params.handlerId) filter += `&handler_id=${params.handlerId}`; if (params.reporterId) filter += `&reporter_id=${params.reporterId}`; if (params.priority) filter += `&priority=${params.priority}`; if (params.severity) filter += `&severity=${params.severity}`; if (params.search) filter += `&search=${encodeURIComponent(params.search)}`; if (params.select?.length) filter += `&select=${params.select.join(',')}`; const pageSize = params.pageSize || 50; const page = params.page ||1; const cacheKey = `issues-${filter}-${page}-${pageSize}`; const response = await this.cachedRequest<{issues: Issue[]}>(cacheKey, () => { return this.api.get(`/issues?page=${page}&page_size=${pageSize}${filter}`); }); return response.issues; }
- src/services/mantisApi.ts:43-54 (schema)TypeScript interface defining the shape of IssueSearchParams used in mantisApi.getIssues function.export interface IssueSearchParams { projectId?: number; statusId?: number; handlerId?: number; reporterId?: number; priority?: number; severity?: number; pageSize?: number; page?: number; search?: string; select?: string[]; }