Skip to main content
Glama

update_project_v2_item_field

Modify field values for items in GitHub Projects V2 using the GraphQL API. Specify project, item, and field IDs to update and assign new values effectively.

Instructions

Update a field value for an item in a GitHub project V2 using GraphQL API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldIdYesThe node ID of the field
itemIdYesThe node ID of the item
projectIdYesThe node ID of the project
valueNoThe new value for the field

Implementation Reference

  • The core handler function that executes the GraphQL mutation to update a ProjectV2 item field value, handling different value types (text, date, single select, number).
    export async function updateProjectV2ItemFieldValue(projectId: string, itemId: string, fieldId: string, value: any) { try { const query = ` mutation($input: UpdateProjectV2ItemFieldValueInput!) { updateProjectV2ItemFieldValue(input: $input) { projectV2Item { id } } } `; // Phân tích kiểu giá trị để tạo input phù hợp let fieldValue; if (typeof value === 'string') { // Text field fieldValue = { text: value }; } else if (value instanceof Date) { // Date field fieldValue = { date: value.toISOString() }; } else if (typeof value === 'object' && value.optionId) { // Single select field fieldValue = { singleSelectOptionId: value.optionId }; } else if (typeof value === 'number') { // Number field fieldValue = { number: value }; } else { throw new GitHubError( `Unsupported field value type`, 400, { error: 'Unsupported field value type' } ); } const variables = { input: { projectId, itemId, fieldId, value: fieldValue } }; const response = await graphqlRequest(query, variables); return response.data.updateProjectV2ItemFieldValue.projectV2Item; } catch (error) { if (error instanceof GitHubError) { throw error; } throw new GitHubError( `Failed to update project v2 item field value: ${(error as Error).message}`, 500, { error: (error as Error).message } ); } }
  • Zod schema defining the input parameters: projectId, itemId, fieldId, and value for the update_project_v2_item_field tool.
    export const UpdateProjectV2ItemFieldValueSchema = z.object({ projectId: z.string().describe("The node ID of the project"), itemId: z.string().describe("The node ID of the item"), fieldId: z.string().describe("The node ID of the field"), value: z.any().describe("The new value for the field") });
  • index.ts:300-304 (registration)
    Tool registration in the MCP server's listTools response, specifying name, description, and input schema.
    { name: "update_project_v2_item_field", description: "Update a field value for an item in a GitHub project V2 using GraphQL API", inputSchema: zodToJsonSchema(projectsV2.UpdateProjectV2ItemFieldValueSchema), }
  • MCP server handler that parses tool arguments and delegates to the projectsV2.updateProjectV2ItemFieldValue function.
    case "update_project_v2_item_field": { const args = projectsV2.UpdateProjectV2ItemFieldValueSchema.parse(request.params.arguments); const result = await projectsV2.updateProjectV2ItemFieldValue( args.projectId, args.itemId, args.fieldId, args.value ); 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