Skip to main content
Glama

add_item_to_project_v2

Add GitHub issues or pull requests to a project V2 by specifying the project and content node IDs using the GraphQL API, streamlining project management workflows.

Instructions

Add an issue or pull request to a GitHub project V2 using GraphQL API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentIdYesThe node ID of the issue or pull request to add
projectIdYesThe node ID of the project

Implementation Reference

  • The core handler function that performs the GraphQL mutation to add an item (issue or PR) to a ProjectV2.
    export async function addItemToProjectV2(projectId: string, contentId: string) {
      try {
        const query = `
          mutation($input: AddProjectV2ItemByIdInput!) {
            addProjectV2ItemById(input: $input) {
              item {
                id
                content {
                  ... on Issue {
                    id
                    title
                    number
                  }
                  ... on PullRequest {
                    id
                    title
                    number
                  }
                }
              }
            }
          }
        `;
    
        const variables = {
          input: {
            projectId,
            contentId
          }
        };
    
        const response = await graphqlRequest(query, variables);
    
        return response.data.addProjectV2ItemById.item;
      } catch (error) {
        if (error instanceof GitHubError) {
          throw error;
        }
    
        throw new GitHubError(
          `Failed to add item to project v2: ${(error as Error).message}`,
          500,
          { error: (error as Error).message }
        );
      }
  • Zod schema defining the input parameters: projectId and contentId.
    export const AddItemToProjectV2Schema = z.object({
      projectId: z.string().describe("The node ID of the project"),
      contentId: z.string().describe("The node ID of the issue or pull request to add")
    });
  • index.ts:290-294 (registration)
    Tool registration in the MCP server's listTools response, specifying name, description, and input schema.
    {
      name: "add_item_to_project_v2",
      description: "Add an issue or pull request to a GitHub project V2 using GraphQL API",
      inputSchema: zodToJsonSchema(projectsV2.AddItemToProjectV2Schema),
    },
  • Dispatcher case in the callTool handler that parses arguments and invokes the main handler function.
    case "add_item_to_project_v2": {
      const args = projectsV2.AddItemToProjectV2Schema.parse(request.params.arguments);
      const result = await projectsV2.addItemToProjectV2(
        args.projectId,
        args.contentId
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }

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

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