add_project_item
Add issues or pull requests to a GitHub project using project ID, content ID, and content type. Simplify project management by integrating directly with GitHub Projects V2.
Instructions
Add an item to a GitHub project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentId | Yes | ||
| contentType | Yes | ||
| projectId | Yes |
Implementation Reference
- Core handler function that executes the GitHub GraphQL mutation to add a project item (issue or pull request). Constructs ProjectItem response object.async addProjectItem(data: { projectId: string; contentId: string; contentType: 'issue' | 'pull_request'; }): Promise<ProjectItem> { try { // GraphQL mutation to add an item to a project const mutation = ` mutation($input: AddProjectV2ItemByIdInput!) { addProjectV2ItemById(input: $input) { item { id content { ... on Issue { id title } ... on PullRequest { id title } } } } } `; interface AddProjectItemResponse { addProjectV2ItemById: { item: { id: string; content: { id: string; title: string; }; }; }; } const response = await this.factory.graphql<AddProjectItemResponse>(mutation, { input: { projectId: data.projectId, contentId: data.contentId } }); const itemId = response.addProjectV2ItemById.item.id; const contentId = response.addProjectV2ItemById.item.content.id; const resourceType = data.contentType === 'issue' ? ResourceType.ISSUE : ResourceType.PULL_REQUEST; return { id: itemId, contentId, contentType: resourceType, projectId: data.projectId, fieldValues: {}, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }; } catch (error) { throw this.mapErrorToMCPError(error); } }
- ToolDefinition object including name, description, input schema (addProjectItemSchema), and usage examples for the add_project_item tool.export const addProjectItemTool: ToolDefinition<AddProjectItemArgs> = { name: "add_project_item", description: "Add an item to a GitHub project", schema: addProjectItemSchema as unknown as ToolSchema<AddProjectItemArgs>, examples: [ { name: "Add issue to project", description: "Add an existing issue to a project", args: { projectId: "PVT_kwDOLhQ7gc4AOEbH", contentId: "I_kwDOJrIzLs5eGXAT", contentType: "issue" } } ] };
- src/infrastructure/tools/ToolRegistry.ts:253-257 (registration)Registers the addProjectItemTool (imported from ToolSchemas) in the central ToolRegistry singleton.this.registerTool(addProjectItemTool); this.registerTool(removeProjectItemTool); this.registerTool(listProjectItemsTool); this.registerTool(archiveProjectItemTool); this.registerTool(unarchiveProjectItemTool);
- src/index.ts:406-407 (handler)MCP server request handler dispatches 'add_project_item' tool calls to ProjectManagementService.addProjectItem(args).case "add_project_item": return await this.service.addProjectItem(args);
- Zod input schema validation for add_project_item tool parameters.export const addProjectItemSchema = z.object({ projectId: z.string().min(1, "Project ID is required"), contentId: z.string().min(1, "Content ID is required"), contentType: z.enum(["issue", "pull_request"]), }); export type AddProjectItemArgs = z.infer<typeof addProjectItemSchema>;