add_attachment_from_public_url
Attach files from a public URL to a Jira ticket using the /rest/api/3/issue/{issueIdOrKey}/attachments endpoint for streamlined file management.
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 |
|---|---|---|---|
| imageUrl | Yes | The URL of the image to attach | |
| issueIdOrKey | Yes | The issue id or key |
Implementation Reference
- src/index.ts:365-396 (handler)The core handler function that downloads the image from the public URL using axios, creates a FormData blob, and uploads it as an attachment to the specified Jira issue via the REST API.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:923-941 (registration)Registers the tool handler in the MCP CallToolRequestSchema switch statement, validates arguments, calls the addAttachment function, and formats the 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:243-261 (schema)Defines the tool name, description, and input schema (issueIdOrKey and imageUrl) in the ListTools response.{ 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'], }, },