Add create_issue tool and update README with usage examples

This commit is contained in:
sha
2026-03-20 14:13:30 +02:00
parent 3a701a5280
commit 1bfb98b7c0
3 changed files with 46 additions and 1 deletions
+8
View File
@@ -24,3 +24,11 @@ def _put(path: str, body: dict) -> dict:
resp = client.put(url, headers=_headers(), content=json.dumps(body))
resp.raise_for_status()
return resp.json() if resp.content else {}
def _post(path: str, body: dict) -> dict:
url = f"{REDMINE_URL}{path}"
with httpx.Client(timeout=15) as client:
resp = client.post(url, headers=_headers(), content=json.dumps(body))
resp.raise_for_status()
return resp.json()
+36 -1
View File
@@ -1,6 +1,41 @@
import json
from ..mcp import mcp
from ..client import _get, _put
from ..client import _get, _put, _post
@mcp.tool()
def create_issue(
project_id: str,
subject: str,
description: str = "",
assigned_to_id: int = 0,
priority_id: int = 0,
due_date: str = "",
) -> str:
"""
Create a new Redmine issue.
Args:
project_id: Project ID or slug
subject: Issue title
description: Issue description
assigned_to_id: User ID to assign (use get_project_members to find IDs)
priority_id: Priority ID (leave 0 for default)
due_date: Due date in YYYY-MM-DD format
"""
payload: dict = {"project_id": project_id, "subject": subject}
if description:
payload["description"] = description
if assigned_to_id:
payload["assigned_to_id"] = assigned_to_id
if priority_id:
payload["priority_id"] = priority_id
if due_date:
payload["due_date"] = due_date
data = _post("/issues.json", {"issue": payload})
issue = data["issue"]
return json.dumps({"id": issue["id"], "subject": issue["subject"]}, ensure_ascii=False, indent=2)
@mcp.tool()