Skip to main content
Glama
kunwarVivek

mcp-github-project-manager

create_project_field

Add custom fields to GitHub projects to organize tasks with specific data types like text, numbers, dates, or selections.

Instructions

Create a custom field for a GitHub project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYes
nameYes
typeYes
optionsNo
descriptionNo
requiredNo

Implementation Reference

  • Executes the GitHub GraphQL mutation 'createProjectV2Field' to create a custom field in a GitHub project, handling different field types including single_select with options and iteration fields with config. Fetches additional details post-creation.
    async createField(projectId: ProjectId, field: Omit<CustomField, "id">): Promise<CustomField> {
      const mutation = `
        mutation($input: CreateProjectV2FieldInput!) {
          createProjectV2Field(input: $input) {
            projectV2Field {
              id
              name
              dataType
            }
          }
        }
      `;
    
      try {
        const githubFieldType = mapToGraphQLFieldType(field.type);
        
        const variables: any = {
          input: {
            projectId,
            dataType: githubFieldType,
            name: field.name,
          }
        };
    
        if (field.type === 'single_select' && field.options && field.options.length > 0) {
          variables.input.singleSelectOptions = field.options.map(option => ({
            name: option.name,
            description: option.description || null,
            color: option.color || null
          }));
        }
    
        if (field.type === 'iteration' && field.config) {
          if (field.config.iterationDuration) {
            variables.input.iterationDuration = field.config.iterationDuration;
          }
          if (field.config.iterationStart) {
            variables.input.iterationStartDate = field.config.iterationStart;
          }
        }
    
        const response = await this.graphql<CreateProjectV2FieldResponse>(mutation, variables);
        const createdField = response.createProjectV2Field.projectV2Field;
    
        // Since the createdField object doesn't have a dataType property, we need to fetch it
        const fieldDetails = await this.getField(projectId, createdField.id);
        
        return {
          id: createdField.id,
          name: createdField.name,
          type: fieldDetails?.type || field.type, // Use fetched type or fallback to original
          options: field.options || [],
          description: field.description,
          required: field.required || false,
          defaultValue: field.defaultValue,
          validation: field.validation,
          config: field.config
        };
      } catch (error) {
        this.logger.error(`Failed to create field ${field.name} for project ${projectId}`, error);
        throw this.handleGraphQLError(error);
      }
    }
  • Zod schema defining input parameters for the create_project_field tool: projectId, name, type (text/number/date/single_select/iteration/milestone/assignees/labels), optional options array, description, and required flag.
    export const createProjectFieldSchema = z.object({
      projectId: z.string().min(1, "Project ID is required"),
      name: z.string().min(1, "Field name is required"),
      type: z.enum([
        "text",
        "number",
        "date",
        "single_select",
        "iteration",
        "milestone",
        "assignees",
        "labels"
      ]),
      options: z.array(
        z.object({
          name: z.string().min(1),
          description: z.string().optional(),
          color: z.string().optional(),
        })
      ).optional(),
      description: z.string().optional(),
      required: z.boolean().optional(),
    });
    
    export type CreateProjectFieldArgs = z.infer<typeof createProjectFieldSchema>;
  • ToolDefinition object registering the create_project_field tool with name, description, input schema, and example usage for creating a status single-select field.
    export const createProjectFieldTool: ToolDefinition<CreateProjectFieldArgs> = {
      name: "create_project_field",
      description: "Create a custom field for a GitHub project",
      schema: createProjectFieldSchema as unknown as ToolSchema<CreateProjectFieldArgs>,
      examples: [
        {
          name: "Create status field",
          description: "Create a status dropdown field for a project",
          args: {
            projectId: "PVT_kwDOLhQ7gc4AOEbH",
            name: "Status",
            type: "single_select",
            options: [
              { name: "To Do", color: "red" },
              { name: "In Progress", color: "yellow" },
              { name: "Done", color: "green" }
            ],
            description: "Current status of the task",
            required: true
          }
        }
      ]
    };
  • Registers the createProjectFieldTool in the central ToolRegistry singleton during built-in tools initialization.
    this.registerTool(createProjectFieldTool);
Install Server

Other Tools

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/kunwarVivek/mcp-github-project-manager'

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