Skip to main content
Glama
kunwarVivek

mcp-github-project-manager

create_automation_rule

Create automation rules for GitHub projects to trigger actions based on events like issue changes, PR updates, or scheduled tasks.

Instructions

Create a new automation rule for a GitHub project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
descriptionNo
projectIdYes
enabledYes
triggersYes
actionsYes

Implementation Reference

  • Core handler implementing the GitHub GraphQL mutation to create ProjectV2 automation rules
    async create(data: CreateAutomationRule): Promise<AutomationRule> {
      const mutation = `
        mutation($input: CreateProjectV2RuleInput!) {
          createProjectV2Rule(input: $input) {
            projectRule {
              id
              databaseId
              createdAt
              updatedAt
              isActive
              name
              ruleTrigger {
                type
                whenStateEquals
                whenStateWas
                whenFieldValueEquals
                whenFieldId
              }
              ruleActions {
                type
                fieldId
                value
                projectItemId
                sourceFieldId
                targetFieldId
                labelName
                milestoneId
              }
            }
          }
        }
      `;
    
      try {
        const variables = this.prepareCreateRuleVariables(data);
        const response = await this.graphql<CreateProjectRuleResponse>(mutation, variables);
        return this.mapGitHubRuleToAutomationRule(response.createProjectV2Rule.projectRule, data.projectId);
      } catch (error) {
        this.logger.error(`Failed to create automation rule for project ${data.projectId}`, error);
        throw this.handleGraphQLError(error);
      }
    }
  • Service layer handler that validates input, checks project existence, and delegates to repository
    async createAutomationRule(data: {
      name: string;
      description?: string;
      projectId: string;
      enabled?: boolean;
      triggers: Array<{
        type: string;
        resourceType?: string;
        conditions?: Array<{
          field: string;
          operator: string;
          value: any;
        }>;
      }>;
      actions: Array<{
        type: string;
        parameters: Record<string, any>;
      }>;
    }): Promise<{
      id: string;
      name: string;
      description?: string;
      projectId: string;
      enabled: boolean;
      triggers: any[];
      actions: any[];
    }> {
      try {
        // Verify project exists
        const project = await this.projectRepo.findById(data.projectId);
        if (!project) {
          throw new ResourceNotFoundError(ResourceType.PROJECT, data.projectId);
        }
    
        const rule = await this.automationRepo.create({
          name: data.name,
          description: data.description,
          projectId: data.projectId,
          enabled: data.enabled ?? true,
          triggers: data.triggers as any,
          actions: data.actions as any
        });
    
        return {
          id: rule.id,
          name: rule.name,
          description: rule.description,
          projectId: rule.projectId,
          enabled: rule.enabled,
          triggers: rule.triggers,
          actions: rule.actions
        };
      } catch (error) {
        throw this.mapErrorToMCPError(error);
      }
  • MCP tool definition including name, description, input schema, and examples
    export const createAutomationRuleTool: ToolDefinition<CreateAutomationRuleArgs> = {
      name: "create_automation_rule",
      description: "Create a new automation rule for a GitHub project",
      schema: createAutomationRuleSchema as unknown as ToolSchema<CreateAutomationRuleArgs>,
      examples: [
        {
          name: "Auto-label PRs",
          description: "Automatically add 'needs-review' label when PR is opened",
          args: {
            name: "Auto-label new PRs",
            projectId: "PVT_kwDOLhQ7gc4AOEbH",
            enabled: true,
            triggers: [{
              type: "pr_opened"
            }],
            actions: [{
              type: "add_label",
              parameters: { labelName: "needs-review" }
            }]
          }
        },
        {
          name: "Auto-assign issues",
          description: "Automatically assign issues with 'bug' label to maintainer",
          args: {
            name: "Auto-assign bugs",
            projectId: "PVT_kwDOLhQ7gc4AOEbH",
            enabled: true,
            triggers: [{
              type: "issue_labeled",
              conditions: [{
                field: "label",
                operator: "equals",
                value: "bug"
              }]
            }],
            actions: [{
              type: "assign_user",
              parameters: { username: "maintainer" }
            }]
          }
        }
      ]
    };
  • Registers the create_automation_rule tool in the central ToolRegistry singleton
    this.registerTool(createAutomationRuleTool);
    this.registerTool(updateAutomationRuleTool);
    this.registerTool(deleteAutomationRuleTool);
    this.registerTool(getAutomationRuleTool);
    this.registerTool(listAutomationRulesTool);
    this.registerTool(enableAutomationRuleTool);
    this.registerTool(disableAutomationRuleTool);
  • Domain type definition for CreateAutomationRule input structure used across services and repository
    export interface CreateAutomationRule {
      name: string;
      description?: string;
      projectId: string;
      enabled?: boolean;
      triggers: Omit<AutomationTrigger, "id">[];
      actions: Omit<AutomationAction, "id">[];
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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