Skip to main content
Glama
yuezheng2006

Personal JIRA MCP

by yuezheng2006

download_all_attachments

Download all attachments from a JIRA issue to your local system by providing the issue key.

Instructions

下载JIRA问题的所有附件到本地

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issue_keyYes

Implementation Reference

  • The @mcp.tool decorator that registers the download_all_attachments function as an MCP tool.
    @mcp.tool(
        description="下载JIRA问题的所有附件到本地",
    )
  • The core handler function implementing the logic to download all attachments for the specified JIRA issue key to a local directory, including error handling and result reporting.
    def download_all_attachments(
        issue_key: str,
    ) -> Dict[str, Any]:
        """下载JIRA问题的所有附件到本地.
        
        Args:
            issue_key: JIRA问题键
        
        Returns:
            Dict[str, Any]: 下载结果
        """
        logger.info(f"下载问题所有附件: {issue_key}")
        try:
            client = get_jira_client()
            issue = client.issue(issue_key)
            
            downloads = []
            failed = []
            
            # 获取附件列表
            attachments = []
            if hasattr(issue.fields, "attachment") and issue.fields.attachment:
                attachments = issue.fields.attachment
            
            if not attachments:
                return {
                    "issue_key": issue_key,
                    "message": "此问题没有附件",
                    "total": 0,
                    "downloads": []
                }
            
            # 为此问题创建目录
            issue_dir = os.path.join(ATTACHMENTS_DIR, issue_key)
            os.makedirs(issue_dir, exist_ok=True)
            
            # 下载每个附件
            for attachment in attachments:
                try:
                    file_path = os.path.join(issue_dir, attachment.filename)
                    
                    # 下载内容
                    content = attachment.get()
                    
                    # 保存到文件
                    with open(file_path, "wb") as f:
                        f.write(content)
                    
                    downloads.append({
                        "id": attachment.id,
                        "filename": attachment.filename,
                        "size": os.path.getsize(file_path),
                        "content_type": attachment.mimeType,
                        "local_path": file_path
                    })
                except Exception as e:
                    logger.error(f"下载附件 {attachment.filename} 失败: {str(e)}")
                    failed.append({
                        "filename": attachment.filename,
                        "error": str(e)
                    })
            
            return {
                "issue_key": issue_key,
                "total": len(attachments),
                "success": len(downloads),
                "failed": len(failed),
                "download_dir": issue_dir,
                "downloads": downloads,
                "failures": failed if failed else None
            }
        except Exception as e:
            logger.error(f"下载问题 {issue_key} 的所有附件失败: {str(e)}")
            return {"error": str(e)}
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states the tool downloads attachments to local storage, implying a write operation to the local system, but doesn't disclose behavioral traits such as file naming conventions, overwrite behavior, download location, network usage, or error handling. This leaves significant gaps for a tool that performs I/O operations.

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 in Chinese that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 download operation (with no annotations, 0% schema coverage, and no output schema), the description is incomplete. It doesn't address key aspects like what happens if there are no attachments, how files are saved, or what the tool returns (e.g., success status, file paths). For a tool that interacts with external systems and local storage, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, and the description provides no information about the 'issue_key' parameter beyond what the schema title ('Issue Key') implies. It doesn't explain the format, examples, or constraints for the issue key, failing to compensate for the lack of schema 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 ('下载' meaning 'download') and resource ('JIRA问题的所有附件' meaning 'all attachments of a JIRA issue'), making the purpose understandable. It doesn't explicitly distinguish from sibling tools like 'get_attachment_by_filename' or 'get_issue_attachments', which appear to be read-only operations, but the download action implies a local storage outcome.

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?

No guidance is provided on when to use this tool versus alternatives like 'get_issue_attachments' (which might list attachments without downloading) or 'get_attachment_by_filename' (which might download a specific file). The description implies it's for bulk downloading all attachments, but doesn't specify prerequisites, error conditions, or exclusions.

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

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