Skip to main content
Glama

get_issue_attachments

Retrieve and optionally download all attachments for a specified JIRA issue from the Personal JIRA MCP server, streamlining file management and access.

Instructions

获取JIRA问题的所有附件

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
downloadNo
issue_keyYes

Implementation Reference

  • The handler function for the MCP tool 'get_issue_attachments'. It lists attachments for a JIRA issue, checks local existence, and optionally downloads all if download=True by calling another tool.
    @mcp.tool( description="获取JIRA问题的所有附件", ) def get_issue_attachments( issue_key: str, download: bool = False ) -> Dict[str, Any]: """获取JIRA问题的所有附件信息. Args: issue_key: JIRA问题键 download: 是否下载附件到本地 Returns: Dict[str, Any]: 附件列表 """ logger.info(f"获取问题附件列表: {issue_key}, download={download}") if download: return download_all_attachments(issue_key) try: client = get_jira_client() issue = client.issue(issue_key) attachments = [] if hasattr(issue.fields, "attachment") and issue.fields.attachment: for attachment in issue.fields.attachment: # 检查附件是否已存在于本地 local_path = get_attachment_path(issue_key, attachment.filename) exists_locally = os.path.exists(local_path) attachments.append({ "id": attachment.id, "filename": attachment.filename, "size": attachment.size, "content_type": attachment.mimeType, "created": str(attachment.created), # 确保日期是字符串 "url": str(attachment.content), # 确保URL是字符串 "local_path": local_path if exists_locally else None, "exists_locally": exists_locally }) return { "issue_key": issue_key, "attachments": attachments, "total": len(attachments), "attachments_dir": os.path.join(ATTACHMENTS_DIR, issue_key) } except Exception as e: logger.error(f"获取问题 {issue_key} 附件列表失败: {str(e)}") return {"error": str(e)}
  • Helper function used by get_issue_attachments to compute local file paths for attachments.
    def get_attachment_path(issue_key: str, filename: str) -> str: """获取附件在本地文件系统中的保存路径.""" # 创建问题专属目录 issue_dir = os.path.join(ATTACHMENTS_DIR, issue_key) os.makedirs(issue_dir, exist_ok=True) return os.path.join(issue_dir, filename)
  • Helper function to lazily initialize and return the JIRA client instance, used by the handler.
    def get_jira_client() -> JIRA: """获取JIRA客户端实例.""" global jira_client if jira_client is None: auth = get_jira_auth() jira_client = JIRA(server=jira_settings.server_url, basic_auth=auth) return jira_client

Other Tools

Related 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/yuezheng2006/mcp-server-jira'

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