add_project_item
Add issues or pull requests to GitHub projects to organize development work and track implementation progress.
Instructions
Add an item to a GitHub project
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | ||
| contentId | Yes | ||
| contentType | Yes |
Input Schema (JSON Schema)
{
"properties": {
"contentId": {
"type": "string"
},
"contentType": {
"enum": [
"issue",
"pull_request"
]
},
"projectId": {
"type": "string"
}
},
"required": [
"projectId",
"contentId",
"contentType"
],
"type": "object"
}
Implementation Reference
- Core handler function that executes the tool logic using GitHub GraphQL API mutation 'addProjectV2ItemById' to add an issue or pull request to a project.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); } }
- Zod schema defining input validation for the tool: projectId, contentId, and contentType (issue or pull_request). Includes TypeScript type inference.// Schema for add_project_item tool 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>;
- src/infrastructure/tools/ToolRegistry.ts:179-179 (registration)Registers the addProjectItemTool in the central ToolRegistry singleton instance.this.registerTool(addProjectItemTool);
- src/infrastructure/tools/ToolRegistry.ts:32-32 (registration)Imports the addProjectItemTool from ToolSchemas for registration.addProjectItemTool,
- src/index.ts:333-334 (handler)Dispatcher in main server that routes tool calls to ProjectManagementService.addProjectItem.case "add_project_item": return await this.service.addProjectItem(args);