Skip to main content
Glama
KS-GEN-AI

Jira MCP Server

by KS-GEN-AI

add_attachment_from_confluence

Add attachments from Confluence pages to Jira tickets using page ID and attachment name to link documentation and files.

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
issueIdOrKeyYesThe issue id or key
pageIdYesThe page id
attachmentNameYesThe name of the attachment

Implementation Reference

  • The main handler function that retrieves an attachment from a Confluence page by pageId and attachmentName, downloads it, and attaches 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,
        };
      }
    }
  • src/index.ts:262-284 (registration)
    Tool registration in the list of available tools, including description and input schema definition.
    {
      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'],
      },
    },
  • Input schema definition for the tool parameters.
    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'],
  • Dispatcher case in the CallToolRequestSchema handler that validates arguments and calls the addAttachmentFromConfluence handler.
    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),
          },
        ],
      };
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It only gives the API endpoint and an odd instruction about markdown. Missing details on whether the tool mutates data, required permissions, side effects, or response behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, brief. The second sentence, 'Do not use markdown in your query,' seems out of place and may confuse the agent. Otherwise concise but could be clearer and more informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description lacks key contextual information for a write operation. It does not specify return values, success/failure indicators, prerequisites, or potential errors. Inadequate for fully understanding tool behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage, so each parameter's meaning is clear from schema. The description adds 'by its name' which is slightly ambiguous given the pageId parameter. No significant additional semantic value beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool adds an attachment from Confluence to a Jira ticket, referencing the API endpoint. It distinguishes from siblings like 'add_attachment_from_public_url'. However, mentioning 'by its name' slightly confuses because the parameter is a pageId, not a name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives. The sibling 'add_attachment_from_public_url' exists but is not compared. The description implies Confluence source but does not state when not to use or provide exclusion criteria.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.