Skip to main content
Glama

add_issue_to_project

Link an existing GitHub issue to a Project V2 for better organization and tracking within your workflow.

Instructions

Add an existing GitHub issue to a Project V2.

Args: owner: The GitHub organization or user name that owns the project project_number: The project number issue_owner: The owner of the repository containing the issue issue_repo: The repository name containing the issue issue_number: The issue number Returns: A formatted string confirming the addition

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYes
project_numberYes
issue_ownerYes
issue_repoYes
issue_numberYes

Implementation Reference

  • The MCP tool handler function for 'add_issue_to_project', registered with @mcp.tool(). It handles input parameters, calls the GitHubClient helper method, formats the response, and manages errors.
    @mcp.tool() async def add_issue_to_project( owner: str, project_number: int, issue_owner: str, issue_repo: str, issue_number: int, ) -> str: """Add an existing GitHub issue to a Project V2. Args: owner: The GitHub organization or user name that owns the project project_number: The project number issue_owner: The owner of the repository containing the issue issue_repo: The repository name containing the issue issue_number: The issue number Returns: A formatted string confirming the addition """ try: result = await github_client.add_issue_to_project( owner, project_number, issue_owner, issue_repo, issue_number ) return ( f"Successfully added issue {issue_owner}/{issue_repo}#{issue_number} to project #{project_number}!\n" f"Item ID: {result['id']}" ) except GitHubClientError as e: logger.error( f"Error adding issue {issue_owner}/{issue_repo}#{issue_number} to project {owner}/{project_number}: {e}" ) return f"Error: Could not add issue to project. Details: {e}"
  • The GitHubClient helper method that performs the core logic: resolves project and issue node IDs via GraphQL queries, then executes the addProjectV2ItemById mutation to add the issue to the project.
    async def add_issue_to_project( self, owner: str, project_number: int, issue_owner: str, issue_repo: str, issue_number: int, ) -> Dict[str, Any]: """Add an existing GitHub issue to a Project V2. Args: owner: The GitHub organization or user name that owns the project project_number: The project number issue_owner: The owner of the repository containing the issue issue_repo: The repository name containing the issue issue_number: The issue number Returns: The project item data Raises: GitHubClientError: If project or issue is 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 issue: {e}") raise # Get issue ID issue_query = """ query GetIssueId($owner: String!, $repo: String!, $number: Int!) { repository(owner: $owner, name: $repo) { issue(number: $number) { id } } } """ issue_variables = { "owner": issue_owner, "repo": issue_repo, "number": issue_number, } try: issue_result = await self.execute_query(issue_query, issue_variables) if not issue_result.get("repository") or not issue_result["repository"].get( "issue" ): raise GitHubClientError( f"Issue {issue_number} not found in {issue_owner}/{issue_repo}" ) except GitHubClientError as e: logger.error( f"Failed to get issue ID for {issue_owner}/{issue_repo}#{issue_number}: {e}" ) raise issue_id = issue_result["repository"]["issue"]["id"] # Add issue to project add_query = """ mutation AddItemToProject($projectId: ID!, $contentId: ID!) { addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) { item { id content { ... on Issue { title number } ... on PullRequest { title number } } } } } """ variables = {"projectId": project_id, "contentId": issue_id} try: result = await self.execute_query(add_query, variables) if not result.get("addProjectV2ItemById") or not result[ "addProjectV2ItemById" ].get("item"): raise GitHubClientError( f"Failed to add issue {issue_number} to project {project_number}" ) return result["addProjectV2ItemById"]["item"] except GitHubClientError as e: logger.error( f"Failed to add issue {issue_number} 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