linear_get_attachments
Retrieve file attachments associated with a specific Linear issue to access supporting documents and media files.
Instructions
Get attachments for an issue in Linear
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueId | Yes | Issue ID to get attachments for |
Implementation Reference
- The main handler function that implements the tool logic: validates the issueId input, uses mock data to simulate fetching attachments from Linear, formats the response as JSON, and handles errors.export const linearGetAttachmentsHandler = async ( args: ToolArgs ): Promise<{ content: Array<{ type: string; text: string }>; isError?: boolean; }> => { try { // Type check and validate the input if (!args.issueId || typeof args.issueId !== 'string') { throw new Error('Issue ID is required and must be a string'); } // Extract the issueId const issueId = args.issueId; // In a real implementation, we would use linearClient.issue(issueId) // and then issue.attachments() // First, check if issue exists const mockIssues: Record<string, { id: string; title: string; attachments: AttachmentData[] }> = { issue1: { id: 'issue1', title: 'Test Issue 1', attachments: [ { id: 'attachment1', url: 'https://example.com/doc1.pdf', title: 'Requirements Document', subtitle: 'Project requirements', icon: 'https://example.com/pdf-icon.png', createdAt: '2023-03-01T12:00:00Z', }, { id: 'attachment2', url: 'https://example.com/design.png', title: 'Design Mockup', subtitle: 'UI design', icon: 'https://example.com/image-icon.png', createdAt: '2023-03-02T14:30:00Z', }, ], }, issue2: { id: 'issue2', title: 'Test Issue 2', attachments: [ { id: 'attachment3', url: 'https://example.com/spec.pdf', title: 'Technical Specification', createdAt: '2023-03-03T09:15:00Z', }, ], }, issue3: { id: 'issue3', title: 'Test Issue 3', attachments: [], }, }; if (!mockIssues[issueId]) { throw new Error(`Issue with ID ${issueId} not found`); } const attachments = mockIssues[issueId].attachments; // Format the response return { content: [ { type: 'text', text: JSON.stringify( { success: true, issueId, issueTitle: mockIssues[issueId].title, attachments, totalCount: attachments.length, }, null, 2 ), }, ], }; } catch (error) { console.error('Error in linear_get_attachments:', error); return { content: [ { type: 'text', text: `Error: ${(error as Error).message || String(error)}`, }, ], isError: true, }; } };
- Tool definition object containing the name, description, and inputSchema for parameter validation (requires 'issueId' string).export const linearGetAttachmentsTool = { name: 'linear_get_attachments', description: 'Get attachments for an issue in Linear', inputSchema: { type: 'object' as const, properties: { issueId: { type: 'string', description: 'Issue ID to get attachments for', }, }, required: ['issueId'], }, };
- src/tools/linear_get_attachments.ts:139-139 (registration)Registers the tool definition and handler function with the MCP registry.registerTool(linearGetAttachmentsTool, linearGetAttachmentsHandler);