Skip to main content
Glama

get_jira_issue

Retrieve detailed information for a specific Jira issue by providing its issue key, enabling efficient issue tracking and management on the Jira MCP Server.

Instructions

Get details for a specific Jira issue by key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issue_keyYesThe issue key (e.g., PROJECT-123)

Implementation Reference

  • The handler function that implements the core logic for retrieving a specific Jira issue by its key using the JIRA Python client library. It handles connection if needed, fetches the issue, extracts key fields like summary, status, assignee, comments, and custom fields, and returns a structured JiraIssueResult.
    def get_jira_issue(self, issue_key: str) -> JiraIssueResult:
        """Get details for a specific issue by key"""
        if not self.client:
            if not self.connect():
                # Connection failed - provide clear error message
                raise ValueError(
                    f"Failed to connect to Jira server at {self.server_url}. Check your authentication credentials."
                )
    
        try:
            issue = self.client.issue(issue_key)
    
            # Extract comments if available
            comments = []
            if hasattr(issue.fields, "comment") and hasattr(
                issue.fields.comment, "comments"
            ):
                for comment in issue.fields.comment.comments:
                    comments.append(
                        {
                            "author": (
                                getattr(
                                    comment.author, "displayName", str(comment.author)
                                )
                                if hasattr(comment, "author")
                                else "Unknown"
                            ),
                            "body": comment.body,
                            "created": comment.created,
                        }
                    )
    
            # Create a fields dictionary with custom fields
            fields = {}
            for field_name in dir(issue.fields):
                if not field_name.startswith("_") and field_name not in [
                    "comment",
                    "attachment",
                    "summary",
                    "description",
                    "status",
                    "assignee",
                    "reporter",
                    "created",
                    "updated",
                ]:
                    value = getattr(issue.fields, field_name)
                    if value is not None:
                        # Handle special field types
                        if hasattr(value, "name"):
                            fields[field_name] = value.name
                        elif hasattr(value, "value"):
                            fields[field_name] = value.value
                        elif isinstance(value, list):
                            if len(value) > 0:
                                if hasattr(value[0], "name"):
                                    fields[field_name] = [item.name for item in value]
                                else:
                                    fields[field_name] = value
                        else:
                            fields[field_name] = str(value)
    
            return JiraIssueResult(
                key=issue.key,
                summary=issue.fields.summary,
                description=issue.fields.description,
                status=(
                    issue.fields.status.name
                    if hasattr(issue.fields, "status")
                    else None
                ),
                assignee=(
                    issue.fields.assignee.displayName
                    if hasattr(issue.fields, "assignee") and issue.fields.assignee
                    else None
                ),
                reporter=(
                    issue.fields.reporter.displayName
                    if hasattr(issue.fields, "reporter") and issue.fields.reporter
                    else None
                ),
                created=(
                    issue.fields.created if hasattr(issue.fields, "created") else None
                ),
                updated=(
                    issue.fields.updated if hasattr(issue.fields, "updated") else None
                ),
                fields=fields,
                comments=comments,
            )
        except Exception as e:
            print(f"Failed to get issue {issue_key}: {type(e).__name__}: {str(e)}")
            raise ValueError(
                f"Failed to get issue {issue_key}: {type(e).__name__}: {str(e)}"
            )
  • Input schema definition for the 'get_jira_issue' tool, specifying that it requires an 'issue_key' string parameter.
        name=JiraTools.GET_ISSUE.value,
        description="Get details for a specific Jira issue by key",
        inputSchema={
            "type": "object",
            "properties": {
                "issue_key": {
                    "type": "string",
                    "description": "The issue key (e.g., PROJECT-123)",
                }
            },
            "required": ["issue_key"],
        },
    ),
  • Pydantic model defining the output structure returned by the get_jira_issue handler, including essential issue fields and optional detailed fields.
    class JiraIssueResult(BaseModel):
        key: str
        summary: str
        description: Optional[str] = None
        status: Optional[str] = None
        assignee: Optional[str] = None
        reporter: Optional[str] = None
        created: Optional[str] = None
        updated: Optional[str] = None
        fields: Optional[Dict[str, Any]] = None
        comments: Optional[List[Dict[str, Any]]] = None
        watchers: Optional[Dict[str, Any]] = None
        attachments: Optional[List[Dict[str, Any]]] = None
        subtasks: Optional[List[Dict[str, Any]]] = None
        project: Optional[Dict[str, Any]] = None
        issue_links: Optional[List[Dict[str, Any]]] = None
        worklog: Optional[List[Dict[str, Any]]] = None
        timetracking: Optional[Dict[str, Any]] = None
  • Registration of the 'get_jira_issue' tool in the MCP server's call_tool handler, which extracts the issue_key argument and invokes the JiraServer.get_jira_issue method.
    case JiraTools.GET_ISSUE.value:
        logger.info("Calling synchronous tool get_jira_issue...")
        issue_key = arguments.get("issue_key")
        if not issue_key:
            raise ValueError("Missing required argument: issue_key")
        result = jira_server.get_jira_issue(issue_key)
        logger.info("Synchronous tool get_jira_issue completed.")
  • Enum defining the tool names, including 'get_jira_issue' used for registration in list_tools and call_tool.
    class JiraTools(str, Enum):
        GET_PROJECTS = "get_jira_projects"
        GET_ISSUE = "get_jira_issue"
        SEARCH_ISSUES = "search_jira_issues"
        CREATE_ISSUE = "create_jira_issue"
        CREATE_ISSUES = "create_jira_issues"
        ADD_COMMENT = "add_jira_comment"
        GET_TRANSITIONS = "get_jira_transitions"
        TRANSITION_ISSUE = "transition_jira_issue"
        CREATE_PROJECT = "create_jira_project"
        GET_PROJECT_ISSUE_TYPES = "get_jira_project_issue_types"
Install Server

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

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