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),
          },
        ],
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the API endpoint, implying a network call, but does not describe critical behaviors such as authentication requirements, error handling, rate limits, or what happens if the attachment or page doesn't exist. The 'do not use markdown' note adds some context, but overall, the description lacks sufficient detail for safe and effective use in a mutation operation.

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

Conciseness4/5

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

The description is concise, consisting of two sentences that directly state the tool's purpose and a technical constraint. It is front-loaded with the main action, avoiding unnecessary verbosity. However, the second sentence about markdown feels slightly tacked on and could be integrated more smoothly, preventing a perfect score.

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 the complexity of a mutation tool that interacts with two systems (Jira and Confluence), no annotations, and no output schema, the description is inadequate. It fails to address key contextual elements such as authentication needs, error responses, or the format of results. The agent is left with significant gaps in understanding how to invoke this tool successfully and handle potential issues.

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?

The input schema has 100% description coverage, providing clear definitions for all three parameters. The description does not add any meaningful semantic information beyond what the schema already states, such as explaining relationships between parameters or additional constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description neither compensates for gaps nor enhances understanding.

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 action ('Add an attachment') and the resources involved ('to a ticket on Jira from a Confluence page'), specifying the source and destination. It distinguishes from sibling tools like 'add_attachment_from_public_url' by mentioning Confluence as the source, but does not explicitly contrast with other attachment-related tools or explain its unique scope beyond the API endpoint reference.

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?

The description provides minimal guidance, only mentioning not to use markdown in queries, which is a technical constraint rather than usage context. It does not indicate when to use this tool versus alternatives like 'add_attachment_from_public_url' or other ticket modification tools, nor does it specify prerequisites such as needing access to both Jira and Confluence. This leaves the agent without clear direction on appropriate scenarios.

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

Install Server

Other Tools

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