Skip to main content
Glama
cosmix

JIRA MCP Server

by cosmix

add_attachment

Attach files to JIRA issues by providing the issue key, file content in base64 format, and filename. This tool enables users to add documentation, screenshots, or other supporting materials directly to their JIRA tickets.

Instructions

Add a file attachment to a JIRA issue

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issueKeyYesThe key of the issue to add attachment to
fileContentYesBase64 encoded content of the file
filenameYesName of the file to be attached

Implementation Reference

  • Core handler function that performs the actual file upload to Jira issue via REST API endpoint /attachments.
    async addAttachment(
      issueKey: string,
      file: Buffer,
      filename: string
    ): Promise<{ id: string; filename: string }> {
      const formData = new FormData();
      formData.append("file", new Blob([file]), filename);
    
      const headers = new Headers(this.headers);
      headers.delete("Content-Type");
      headers.set("X-Atlassian-Token", "no-check");
    
      const response = await fetch(
        `${this.baseUrl}/rest/api/3/issue/${issueKey}/attachments`,
        {
          method: "POST",
          headers,
          body: formData,
        }
      );
    
      if (!response.ok) {
        await this.handleFetchError(response);
      }
    
      const data = await response.json();
    
      const attachment = data[0];
      return {
        id: attachment.id,
        filename: attachment.filename,
      };
    }
  • MCP tool dispatch handler: validates input, decodes base64 file content, calls JiraApiService.addAttachment, formats response.
    case "add_attachment": {
      if (
        !args.issueKey ||
        typeof args.issueKey !== "string" ||
        !args.fileContent ||
        typeof args.fileContent !== "string" ||
        !args.filename ||
        typeof args.filename !== "string"
      ) {
        throw new McpError(
          ErrorCode.InvalidParams,
          "issueKey, fileContent, and filename are required",
        );
      }
      const fileBuffer = Buffer.from(args.fileContent, "base64");
      const result = await this.jiraApi.addAttachment(
        args.issueKey,
        fileBuffer,
        args.filename,
      );
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                message: `File ${args.filename} attached successfully to issue ${args.issueKey}`,
                attachmentId: result.id,
                filename: result.filename,
              },
              null,
              2,
            ),
          },
        ],
      };
    }
  • Input schema definition for the add_attachment tool, provided in listTools response.
    {
      name: "add_attachment",
      description: "Add a file attachment to a JIRA issue",
      inputSchema: {
        type: "object",
        properties: {
          issueKey: {
            type: "string",
            description: "The key of the issue to add attachment to",
          },
          fileContent: {
            type: "string",
            description: "Base64 encoded content of the file",
          },
          filename: {
            type: "string",
            description: "Name of the file to be attached",
          },
        },
        required: ["issueKey", "fileContent", "filename"],
        additionalProperties: false,
      },
    },
  • src/index.ts:83-266 (registration)
    Tool registration in the listTools request handler, including add_attachment in the tools array.
      tools: [
        {
          name: "search_issues",
          description: "Search JIRA issues using JQL",
          inputSchema: {
            type: "object",
            properties: {
              searchString: {
                type: "string",
                description: "JQL search string",
              },
            },
            required: ["searchString"],
            additionalProperties: false,
          },
        },
        {
          name: "get_epic_children",
          description:
            "Get all child issues in an epic including their comments",
          inputSchema: {
            type: "object",
            properties: {
              epicKey: {
                type: "string",
                description: "The key of the epic issue",
              },
            },
            required: ["epicKey"],
            additionalProperties: false,
          },
        },
        {
          name: "get_issue",
          description:
            "Get detailed information about a specific JIRA issue including comments",
          inputSchema: {
            type: "object",
            properties: {
              issueId: {
                type: "string",
                description: "The ID or key of the JIRA issue",
              },
            },
            required: ["issueId"],
            additionalProperties: false,
          },
        },
        {
          name: "create_issue",
          description: "Create a new JIRA issue",
          inputSchema: {
            type: "object",
            properties: {
              projectKey: {
                type: "string",
                description: "The project key where the issue will be created",
              },
              issueType: {
                type: "string",
                description:
                  'The type of issue to create (e.g., "Bug", "Story", "Task")',
              },
              summary: {
                type: "string",
                description: "The issue summary/title",
              },
              description: {
                type: "string",
                description: "The issue description",
              },
              fields: {
                type: "object",
                description: "Additional fields to set on the issue",
                additionalProperties: true,
              },
            },
            required: ["projectKey", "issueType", "summary"],
            additionalProperties: false,
          },
        },
        {
          name: "update_issue",
          description: "Update an existing JIRA issue",
          inputSchema: {
            type: "object",
            properties: {
              issueKey: {
                type: "string",
                description: "The key of the issue to update",
              },
              fields: {
                type: "object",
                description: "Fields to update on the issue",
                additionalProperties: true,
              },
            },
            required: ["issueKey", "fields"],
            additionalProperties: false,
          },
        },
        {
          name: "get_transitions",
          description: "Get available status transitions for a JIRA issue",
          inputSchema: {
            type: "object",
            properties: {
              issueKey: {
                type: "string",
                description: "The key of the issue to get transitions for",
              },
            },
            required: ["issueKey"],
            additionalProperties: false,
          },
        },
        {
          name: "transition_issue",
          description:
            "Change the status of a JIRA issue by performing a transition",
          inputSchema: {
            type: "object",
            properties: {
              issueKey: {
                type: "string",
                description: "The key of the issue to transition",
              },
              transitionId: {
                type: "string",
                description: "The ID of the transition to perform",
              },
              comment: {
                type: "string",
                description: "Optional comment to add with the transition",
              },
            },
            required: ["issueKey", "transitionId"],
            additionalProperties: false,
          },
        },
        {
          name: "add_attachment",
          description: "Add a file attachment to a JIRA issue",
          inputSchema: {
            type: "object",
            properties: {
              issueKey: {
                type: "string",
                description: "The key of the issue to add attachment to",
              },
              fileContent: {
                type: "string",
                description: "Base64 encoded content of the file",
              },
              filename: {
                type: "string",
                description: "Name of the file to be attached",
              },
            },
            required: ["issueKey", "fileContent", "filename"],
            additionalProperties: false,
          },
        },
        {
          name: "add_comment",
          description: "Add a comment to a JIRA issue",
          inputSchema: {
            type: "object",
            properties: {
              issueIdOrKey: {
                type: "string",
                description: "The ID or key of the issue to add the comment to",
              },
              body: {
                type: "string",
                description: "The content of the comment (plain text)",
              },
            },
            required: ["issueIdOrKey", "body"],
            additionalProperties: false,
          },
        },
      ],
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic action. It doesn't cover important aspects like required permissions, file size limits, supported file types, whether the operation is idempotent, or what happens on failure (e.g., if issue doesn't exist). For a mutation tool with zero annotation coverage, this is insufficient.

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

Conciseness5/5

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

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a straightforward tool and front-loads the essential information without unnecessary elaboration.

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 this is a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., attachment ID, success confirmation), error conditions, or behavioral constraints. The agent would need to guess about important operational aspects beyond the basic action.

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 schema has 100% description coverage, with all three parameters clearly documented in the schema itself. The description adds no additional parameter information beyond what's already in the schema, so it meets the baseline for adequate but not exceptional parameter documentation.

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') and resource ('file attachment to a JIRA issue'), making the tool's purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'update_issue' or 'add_comment' that might also modify issues, missing an opportunity for clearer distinction.

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 no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., issue must exist), exclusions (e.g., cannot attach to epics), or related tools like 'update_issue' for other modifications, leaving the agent without contextual usage information.

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/cosmix/jira-mcp'

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