add_attachment_from_public_url
Attach files from public URLs to Jira tickets using the Jira API. Provide issue ID/key and image URL to add attachments.
Instructions
Add an attachment from a public url to a ticket on Jira on the api /rest/api/3/issue/{issueIdOrKey}/attachments. Do not use markdown in your query.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issueIdOrKey | Yes | The issue id or key | |
| imageUrl | Yes | The URL of the image to attach |
Implementation Reference
- src/index.ts:923-941 (handler)Handler case for 'add_attachment_from_public_url' tool in the request handler switch statement. Extracts parameters issueIdOrKey and imageUrl, validates them, calls the addAttachment helper function, and returns the JSON response.case 'add_attachment_from_public_url': { const issueIdOrKey: any = request.params.arguments?.issueIdOrKey; const imageUrl: any = request.params.arguments?.imageUrl; if (!issueIdOrKey || !imageUrl) { throw new Error('Issue id or key and image URL are required'); } const response = await addAttachment(issueIdOrKey, imageUrl); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }
- src/index.ts:365-396 (helper)Helper function that implements the core logic: downloads the image from the public URL as arraybuffer, creates FormData with it as 'image.png', and POSTs to Jira's attachment endpoint for the specified issue.async function addAttachment( issueIdOrKey: string, imageUrl: string, ): Promise<any> { try { // Télécharger l'image depuis l'URL const imageResponse = await axios.get(imageUrl, { responseType: 'arraybuffer', }); const formData = new FormData(); formData.append('file', new Blob([imageResponse.data]), 'image.png'); // Headers spéciaux pour l'upload de fichiers const headers = { ...getAuthHeaders().headers, 'X-Atlassian-Token': 'no-check', 'Content-Type': 'multipart/form-data', }; const response = await axios.post( `${JIRA_URL}/rest/api/3/issue/${issueIdOrKey}/attachments`, formData, { headers }, ); return response.data; } catch (error: any) { return { error: error.response?.data || error.message, }; } }
- src/index.ts:243-261 (registration)Tool registration in the tools array passed to server.setTools, including name, description, and input schema.{ name: 'add_attachment_from_public_url', description: 'Add an attachment from a public url to a ticket on Jira on the api /rest/api/3/issue/{issueIdOrKey}/attachments. Do not use markdown in your query.', inputSchema: { type: 'object', properties: { issueIdOrKey: { type: 'string', description: 'The issue id or key', }, imageUrl: { type: 'string', description: 'The URL of the image to attach', }, }, required: ['issueIdOrKey', 'imageUrl'], }, },
- src/index.ts:247-260 (schema)Input schema defining the expected arguments: issueIdOrKey (string) and imageUrl (string), both required.inputSchema: { type: 'object', properties: { issueIdOrKey: { type: 'string', description: 'The issue id or key', }, imageUrl: { type: 'string', description: 'The URL of the image to attach', }, }, required: ['issueIdOrKey', 'imageUrl'], },