Commit a66fca11 authored by MD. SHAHIDUL ISLAM's avatar MD. SHAHIDUL ISLAM

feat: Add `create_story_with_subtasks` tool and comprehensive README…

feat: Add `create_story_with_subtasks` tool and comprehensive README documentation for the MCP server.
parent f566467a
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
import os import os
from mcp.server.fastmcp import FastMCP from mcp.server.fastmcp import FastMCP
from jira import JIRA from jira import JIRA
from typing import Optional from typing import Optional, List
# Initialize FastMCP Server # Initialize FastMCP Server
mcp = FastMCP("Dohatec Jira Mcp") mcp = FastMCP("Dohatec Jira Mcp")
...@@ -132,6 +132,43 @@ def create_issue(summary: str, description: str, project_key: str = None, issue_ ...@@ -132,6 +132,43 @@ def create_issue(summary: str, description: str, project_key: str = None, issue_
except Exception as e: except Exception as e:
return f"Error creating issue: {str(e)}" return f"Error creating issue: {str(e)}"
@mcp.tool()
def create_story_with_subtasks(summary: str, description: str, subtasks: List[str], project_key: str = None) -> str:
"""Creates a new Jira Story along with a list of Sub-tasks. If project_key is not provided, uses the active project."""
global ACTIVE_PROJECT
jira = _get_jira()
target_project = project_key or ACTIVE_PROJECT
if not target_project:
return "Error: No project_key provided and no active project is set."
try:
# 1. Create the parent Story
story_dict = {
'project': {'key': target_project},
'summary': summary,
'description': description,
'issuetype': {'name': 'Story'},
}
story_issue = jira.create_issue(fields=story_dict)
# 2. Create the subtasks linked to the parent Story
created_subtasks = []
for st_summary in subtasks:
subtask_dict = {
'project': {'key': target_project},
'summary': st_summary,
'issuetype': {'name': 'Sub-task'},
'parent': {'id': story_issue.key}
}
st_issue = jira.create_issue(fields=subtask_dict)
created_subtasks.append(st_issue.key)
subtasks_str = ", ".join(created_subtasks)
return f"Successfully created Story {story_issue.key} with subtasks: {subtasks_str}. URL: {JIRA_SERVER}/browse/{story_issue.key}"
except Exception as e:
return f"Error creating story with subtasks: {str(e)}"
@mcp.tool() @mcp.tool()
def assign_issue_to_me(issue_key: str) -> str: def assign_issue_to_me(issue_key: str) -> str:
"""Assigns the specified issue to the authenticated user.""" """Assigns the specified issue to the authenticated user."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment