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
| Name | Required | Description | Default |
|---|---|---|---|
| contentId | Yes | The node ID of the issue or pull request to add | |
| projectId | Yes | The node ID of the project |
Implementation Reference
- operations/projectsV2.ts:300-344 (handler)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 } ); }
- operations/projectsV2.ts:37-40 (schema)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), },
- index.ts:781-790 (helper)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) }], }; }