Skip to main content
Glama

create_draft_issue

Create draft issues in GitHub Projects V2 to capture ideas and tasks before formal issue creation.

Instructions

Create a draft issue directly in a GitHub Project V2.

Args:
    owner: The GitHub organization or user name
    project_number: The project number
    title: The draft issue title
    body: The draft issue body (optional)

Returns:
    A confirmation message with the new draft issue details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes
project_numberYes
titleYes
bodyNo

Implementation Reference

  • Handler function for the 'create_draft_issue' tool. Registered via @mcp.tool() decorator. Delegates to GitHubClient.add_draft_issue_to_project and formats response.
    @mcp.tool()
    async def create_draft_issue(
        owner: str, project_number: int, title: str, body: str = ""
    ) -> str:
        """Create a draft issue directly in a GitHub Project V2.
    
        Args:
            owner: The GitHub organization or user name
            project_number: The project number
            title: The draft issue title
            body: The draft issue body (optional)
    
        Returns:
            A confirmation message with the new draft issue details
        """
        try:
            result = await github_client.add_draft_issue_to_project(
                owner, project_number, title, body
            )
            return (
                f"Successfully created draft issue in project #{project_number}!\n"
                f"Item ID: {result['id']}\n"
                f"Title: {title}"
            )
        except GitHubClientError as e:
            logger.error(f"Error creating draft issue in project {project_number}: {e}")
            return f"Error: Could not create draft issue. Details: {e}"
  • Helper method in GitHubClient class that executes the GraphQL mutation addProjectV2DraftIssue to create the draft issue in the project.
    async def add_draft_issue_to_project(
        self, owner: str, project_number: int, title: str, body: str = ""
    ) -> Dict[str, Any]:
        """Add a draft issue to a GitHub Project V2.
    
        Args:
            owner: The GitHub organization or user name that owns the project
            project_number: The project number
            title: The draft issue title
            body: The draft issue body (optional)
    
        Returns:
            The project item data
    
        Raises:
            GitHubClientError: If project not found or adding fails.
        """
        # Get project ID
        try:
            project_id = await self.get_project_node_id(owner, project_number)
        except GitHubClientError as e:
            logger.error(f"Cannot add draft issue: {e}")
            raise
    
        # Add draft issue to project
        add_query = """
        mutation AddDraftIssueToProject($projectId: ID!, $title: String!, $body: String) {
          addProjectV2DraftIssue(input: {
            projectId: $projectId,
            title: $title,
            body: $body
          }) {
            projectItem {
              id
            }
          }
        }
        """
    
        variables = {"projectId": project_id, "title": title, "body": body}
    
        try:
            result = await self.execute_query(add_query, variables)
            if not result.get("addProjectV2DraftIssue") or not result[
                "addProjectV2DraftIssue"
            ].get("projectItem"):
                raise GitHubClientError(
                    f"Failed to add draft issue to project {project_number}"
                )
            return result["addProjectV2DraftIssue"]["projectItem"]
        except GitHubClientError as e:
            logger.error(f"Failed to add draft issue to project {project_number}: {e}")
            raise

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/Arclio/github-projects-mcp'

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