الملفات
GitPasha-MCP-Server/tools/issue_create.py

40 أسطر
1.0 KiB
Python

import json
from helpers import format_error, log
from api import api_create_issue
import httpx
def issue_create_tool(
repo: str,
title: str,
body: str = "",
labels_csv: str = "",
assignees_csv: str = ""
) -> str:
try:
labels = [
x.strip() for x in labels_csv.split(",") if x.strip()
] if labels_csv else None
assignees = [
x.strip() for x in assignees_csv.split(",") if x.strip()
] if assignees_csv else None
item = api_create_issue(
repo,
title=title,
body=body,
labels=labels,
assignees=assignees
)
return json.dumps(
{
"status": "success",
"item": item
},
ensure_ascii=False
)
except httpx.HTTPStatusError as e:
return format_error("Issue create failed", e)
except Exception as e:
log.exception("Unexpected error while creating issue")
return f"{e}"