getIssues
Retrieve JIRA issue details and attachments by providing the issue key, enabling efficient access to task information through the Personal JIRA MCP server.
Instructions
获取JIRA问题及其附件
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| issue_key | Yes |
Implementation Reference
- src/jira_mcp/server.py:612-636 (handler)The handler function for the 'getIssues' MCP tool. It fetches the JIRA issue by key using the JIRA client, formats it with format_issue helper, and returns the structured data including attachments.def getIssues( 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) # 使用format_issue函数来获取JSON可序列化的问题数据 issue_data = format_issue(issue) # 确保附件列表为JSON可序列化对象 return issue_data except Exception as e: logger.error(f"获取问题 {issue_key} 及附件失败: {str(e)}") return {"error": str(e)}
- src/jira_mcp/server.py:609-611 (registration)MCP tool registration decorator for 'getIssues', specifying the tool description.@mcp.tool( description="获取JIRA问题及其附件", )
- src/jira_mcp/server.py:48-129 (helper)Helper function used by getIssues to convert raw JIRA Issue object to a structured, JSON-serializable dictionary, including handling of attachments and custom fields.def format_issue(issue) -> Dict[str, Any]: """格式化JIRA问题为JSON友好格式.""" fields = issue.fields result = { "id": issue.id, "key": issue.key, "self": issue.self, "summary": fields.summary, "description": fields.description or "", "status": { "id": fields.status.id, "name": fields.status.name, "description": fields.status.description, }, "project": { "id": fields.project.id, "key": fields.project.key, "name": fields.project.name, }, "created": fields.created, "updated": fields.updated, } # 添加可选字段 if hasattr(fields, "assignee") and fields.assignee: result["assignee"] = { "name": fields.assignee.name, "display_name": fields.assignee.displayName, "email": getattr(fields.assignee, "emailAddress", ""), } if hasattr(fields, "reporter") and fields.reporter: result["reporter"] = { "name": fields.reporter.name, "display_name": fields.reporter.displayName, "email": getattr(fields.reporter, "emailAddress", ""), } if hasattr(fields, "issuetype") and fields.issuetype: result["issue_type"] = { "id": fields.issuetype.id, "name": fields.issuetype.name, "description": fields.issuetype.description, } if hasattr(fields, "priority") and fields.priority: result["priority"] = { "id": fields.priority.id, "name": fields.priority.name, } if hasattr(fields, "components") and fields.components: result["components"] = [ {"id": c.id, "name": c.name} for c in fields.components ] if hasattr(fields, "labels") and fields.labels: result["labels"] = fields.labels # 处理附件 - JIRA API 使用 "attachment" 字段 if hasattr(fields, "attachment") and fields.attachment: result["attachments"] = [ { "id": attachment.id, "filename": attachment.filename, "size": attachment.size, "content_type": attachment.mimeType, "created": attachment.created, "url": attachment.content } for attachment in fields.attachment ] # 获取自定义字段 for field_name in dir(fields): if field_name.startswith("customfield_"): value = getattr(fields, field_name) if value is not None: result[field_name] = value return result
- src/jira_mcp/server.py:39-46 (helper)Helper function to initialize and return the singleton JIRA client instance, used by getIssues.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