List Issue File Attachments
list_issue_filesRetrieve all file attachments for a given MantisBT issue, including filename, size, content type, and download URL.
Instructions
List all file attachments of a MantisBT issue. Returns an array of attachment objects, each containing id, filename, size in bytes, content_type, and download_url. Returns an empty array if the issue has no attachments.
Use this tool when you need to inspect or enumerate files attached to an issue. To add a new attachment, use upload_file instead. To retrieve full issue details that include attachments alongside other fields, use get_issue instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issue_id | Yes | Numeric issue ID |
Implementation Reference
- src/tools/files.ts:39-50 (handler)The async handler function that executes the 'list_issue_files' tool logic. It calls the MantisClient API to fetch issue data and extracts the attachments array, returning it as JSON text.
async ({ issue_id }) => { try { const result = await client.get<{ issues: Array<{ attachments?: MantisFile[] }> }>(`issues/${issue_id}`); const attachments = result.issues?.[0]?.attachments ?? []; return { content: [{ type: 'text', text: JSON.stringify(attachments, null, 2) }], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: errorText(msg) }], isError: true }; } } - src/tools/files.ts:23-38 (schema)The tool registration metadata: title, description, inputSchema (issue_id: positive integer), and annotations (readOnlyHint, destructiveHint, idempotentHint).
server.registerTool( 'list_issue_files', { title: 'List Issue File Attachments', description: `List all file attachments of a MantisBT issue. Returns an array of attachment objects, each containing id, filename, size in bytes, content_type, and download_url. Returns an empty array if the issue has no attachments. Use this tool when you need to inspect or enumerate files attached to an issue. To add a new attachment, use upload_file instead. To retrieve full issue details that include attachments alongside other fields, use get_issue instead.`, inputSchema: z.object({ issue_id: z.coerce.number().int().positive().describe('Numeric issue ID'), }), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, - src/tools/files.ts:16-51 (registration)The 'registerFileTools' function which calls server.registerTool('list_issue_files', ...) to register the tool with the MCP server.
export function registerFileTools(server: McpServer, client: MantisClient, uploadDir?: string): void { const normalizedUploadDir = uploadDir ? resolve(uploadDir) + sep : undefined; // --------------------------------------------------------------------------- // list_issue_files // --------------------------------------------------------------------------- server.registerTool( 'list_issue_files', { title: 'List Issue File Attachments', description: `List all file attachments of a MantisBT issue. Returns an array of attachment objects, each containing id, filename, size in bytes, content_type, and download_url. Returns an empty array if the issue has no attachments. Use this tool when you need to inspect or enumerate files attached to an issue. To add a new attachment, use upload_file instead. To retrieve full issue details that include attachments alongside other fields, use get_issue instead.`, inputSchema: z.object({ issue_id: z.coerce.number().int().positive().describe('Numeric issue ID'), }), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, }, }, async ({ issue_id }) => { try { const result = await client.get<{ issues: Array<{ attachments?: MantisFile[] }> }>(`issues/${issue_id}`); const attachments = result.issues?.[0]?.attachments ?? []; return { content: [{ type: 'text', text: JSON.stringify(attachments, null, 2) }], }; } catch (error) { const msg = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text', text: errorText(msg) }], isError: true }; } } ); - src/types.ts:71-78 (helper)The MantisFile interface defining the shape of attachment objects returned by the tool (id, file_name, size, content_type, date_added, description).
export interface MantisFile { id: number; file_name: string; size: number; content_type?: string; date_added?: string; description?: string; }