""" title: Jira Pipeline author: PM Factory version: 0.1.0 description: Search and create Jira issues via mcporter + Atlassian MCP. requirements: subprocess """ import subprocess import json import os from typing import Optional MCPORTER_CONFIG = os.environ.get("MCPORTER_CONFIG", "config/mcporter.json") class Tools: def __init__(self): self.valves = self.Valves() class Valves: MCPORTER_CONFIG: str = MCPORTER_CONFIG def jira_search(self, jql: str, __user__: dict = {}) -> str: """ Search Jira issues using JQL. :param jql: JQL query string (e.g. 'project = PLAT AND status = "In Progress"') :return: JSON string of matching issues """ try: result = subprocess.run( [ "mcporter", "--config", self.valves.MCPORTER_CONFIG, "call", "atlassian", "jira_search", "--params", json.dumps({"jql": jql}) ], capture_output=True, text=True, timeout=30 ) if result.returncode != 0: return f"Error: {result.stderr.strip()}" return result.stdout.strip() except Exception as e: return f"Error: {str(e)}" def jira_create(self, project: str, summary: str, description: str, issue_type: str = "Story", __user__: dict = {}) -> str: """ Create a Jira issue. :param project: Jira project key (e.g. 'PLAT') :param summary: Issue title :param description: Issue description (markdown supported) :param issue_type: Issue type (Story, Bug, Epic, Task). Default: Story :return: Created issue key and URL """ params = { "project": project, "summary": summary, "description": description, "issueType": issue_type } try: result = subprocess.run( [ "mcporter", "--config", self.valves.MCPORTER_CONFIG, "call", "atlassian", "jira_create_issue", "--params", json.dumps(params) ], capture_output=True, text=True, timeout=30 ) if result.returncode != 0: return f"Error: {result.stderr.strip()}" return result.stdout.strip() except Exception as e: return f"Error: {str(e)}"