Skip to main content
Glama

MCP-JIRA-Python Server

by Kallows
attach_file.py2.28 kB
import os from typing import List from mcp.types import Tool, TextContent from .base import BaseTool class AttachFileTool(BaseTool): def get_tool_definition(self) -> Tool: return Tool( name="attach_file", description="Add the named filepath file as an attachment to a Jira issue", inputSchema={ "type": "object", "properties": { "issueKey": { "type": "string", "description": "Key of the issue to attach to" }, "filename": { "type": "string", "description": "Name of the attachment file in issue" }, "filepath": { "type": "string", "description": "Filepath is file to attach" } }, "required": ["issueKey", "filename", "filepath"] } ) async def execute(self, arguments: dict) -> List[TextContent]: issue_key = arguments.get("issueKey") filename = arguments.get("filename") filepath = arguments.get("filepath") if not all([issue_key, filename, filepath]): raise ValueError("issueKey, filename, and filepath are required") try: # Check if file exists if not os.path.exists(filepath): raise ValueError(f"File not found: {filepath}") # Check file size (10MB limit) if os.path.getsize(filepath) > 10 * 1024 * 1024: raise ValueError("Attachment too large (max 10MB)") # Use add_attachment which is the correct method in the JIRA API # This does not involve base64 encoding/decoding when used with file paths self.jira.add_attachment(issue_key, filepath, filename=filename) return [TextContent( type="text", text=f'{{"message": "File attached successfully", "filename": "{filename}"}}' )] except Exception as e: raise Exception(f"Failed to attach file: {str(e)}")

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

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