Skip to main content
Glama

add_attachment_from_confluence

Attach files from Confluence to Jira tickets by specifying the issue ID, page ID, and attachment name for streamlined workflow integration.

Instructions

Add an attachment to a ticket on Jira from a Confluence page by its name on the api /rest/api/3/issue/{issueIdOrKey}/attachments. Do not use markdown in your query.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachmentNameYesThe name of the attachment
issueIdOrKeyYesThe issue id or key
pageIdYesThe page id

Implementation Reference

  • The main handler function that downloads an attachment from a Confluence page and uploads it to a Jira issue.
    async function addAttachmentFromConfluence( issueIdOrKey: string, pageId: string, attachmentName: string, ): Promise<any> { try { // Récupérer l'attachement depuis Confluence const response = await axios.get( `${JIRA_URL}/wiki/rest/api/content/${pageId}/child/attachment`, { headers: getAuthHeaders().headers, }, ); // Trouver l'attachement spécifique const attachment = response.data.results.find( (attachment: any) => attachment.title === attachmentName, ); if (!attachment) { return { error: 'Attachment not found', }; } // Télécharger l'attachement const attachmentResponse = await axios.get( `${JIRA_URL}/wiki${attachment._links.download}`, { headers: getAuthHeaders().headers, responseType: 'arraybuffer', }, ); // Créer un FormData et ajouter le fichier const formData = new FormData(); const blob = new Blob([attachmentResponse.data], { type: attachment.mediaType, }); formData.append('file', blob, attachmentName); // Headers spéciaux pour l'upload de fichiers const headers = { ...getAuthHeaders().headers, 'X-Atlassian-Token': 'no-check', 'Content-Type': 'multipart/form-data', }; // Uploader l'attachement sur le ticket Jira const uploadResponse = await axios.post( `${JIRA_URL}/rest/api/3/issue/${issueIdOrKey}/attachments`, formData, { headers }, ); return uploadResponse.data; } catch (error: any) { return { error: error.response?.data || error.message, }; } }
  • Tool definition including name, description, and input schema for validation.
    { name: 'add_attachment_from_confluence', description: 'Add an attachment to a ticket on Jira from a Confluence page by its name 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', }, pageId: { type: 'string', description: 'The page id', }, attachmentName: { type: 'string', description: 'The name of the attachment', }, }, required: ['issueIdOrKey', 'pageId', 'attachmentName'], }, },
  • src/index.ts:943-968 (registration)
    Registration and dispatching logic in the CallToolRequestSchema handler switch statement.
    case 'add_attachment_from_confluence': { const issueIdOrKey: any = request.params.arguments?.issueIdOrKey; const pageId: any = request.params.arguments?.pageId; const attachmentName: any = request.params.arguments?.attachmentName; if (!issueIdOrKey || !pageId || !attachmentName) { throw new Error( 'Issue id or key, page id and attachment name are required', ); } const response = await addAttachmentFromConfluence( issueIdOrKey, pageId, attachmentName, ); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KS-GEN-AI/jira-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server