Skip to main content
Glama
KS-GEN-AI

Jira MCP Server

by KS-GEN-AI

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
NameRequiredDescriptionDefault
issueIdOrKeyYesThe issue id or key
imageUrlYesThe URL of the image to attach

Implementation Reference

  • 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),
          },
        ],
      };
    }
  • 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'],
      },
    },
  • 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'],
    },

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