Skip to main content
Glama
Hive-Academy

π“‚€π“’π“‹Ήπ”Έβ„•π•Œπ”Ήπ•€π•Šπ“‹Ήπ“’π“‚€ - Intelligent Guidance for

by Hive-Academy

init_rules

Initialize workflow rules for AI agents (cursor or copilot) to guide project development. Specify the agent and project root to deploy rules effectively.

Instructions

Initialize Anubis workflow rules to specified AI agent (cursor or copilot)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agentNameYesAI agent to deploy rules for (cursor or copilot)
projectRootNoRoot directory of the target project. Defaults to current working directory.

Implementation Reference

  • MCP tool handler function for 'init_rules'. Handles input validation implicitly via schema, delegates to InitRulesService, and formats MCP response.
    @Tool({
      name: 'init_rules',
      description:
        'Initialize Anubis workflow rules to specified AI agent (cursor or copilot)',
      parameters: InitRulesInputSchema as ZodSchema<InitRulesInput>,
    })
    async InitRules(input: InitRulesInput) {
      try {
        const projectRoot = input.projectRoot || process.cwd();
    
        const result = await this.initRulesService.InitRules(
          input.agentName,
          projectRoot,
        );
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  success: result.success,
                  message:
                    'message' in result ? result.message : 'No message available',
                  data: { targetFile: result.targetFile },
                  timestamp: new Date().toISOString(),
                },
                null,
                2,
              ),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  success: false,
                  error: {
                    message: error.message,
                    code: 'DEPLOY_RULES_ERROR',
                  },
                  timestamp: new Date().toISOString(),
                },
                null,
                2,
              ),
            },
          ],
        };
      }
    }
  • Zod input schema defining parameters for the init_rules tool: agentName (enum) and optional projectRoot.
    const InitRulesInputSchema = z.object({
      agentName: z
        .enum(['cursor', 'copilot', 'roocode', 'kilocode'])
        .describe('AI agent to deploy rules for (cursor or copilot)'),
      projectRoot: z
        .string()
        .optional()
        .describe(
          'Root directory of the target project. Defaults to current working directory.',
        ),
    });
  • Core handler logic for deploying Anubis workflow rules to the specified AI agent. Manages templates, directories, frontmatter, and special handling for roocode/kilocode.
    async InitRules(
      agentName: string,
      projectRoot: string,
    ): Promise<{
      success: boolean;
      message: string;
      targetFile?: string;
    }> {
      const config = this.agentConfigs[agentName];
      if (!config) {
        return {
          success: false,
          message: `Unsupported AI agent: ${agentName}. Supported agents: ${Object.keys(this.agentConfigs).join(', ')}`,
        };
      }
    
      try {
        // Ensure target directories exist
        await this.ensureDirectories(projectRoot, config.ensureDirectories);
    
        // Use the provided template file if specified, otherwise use the default from config
        const templateToUse = config.sourceTemplate;
    
        // Read source template
        const sourceContent = await this.readTemplate(templateToUse);
    
        // Process content (add frontmatter if required)
        const processedContent = config.requiresFrontmatter
          ? this.addFrontmatter(sourceContent, config)
          : sourceContent;
    
        // Write to target location
        const targetFilePath = path.join(
          projectRoot,
          config.targetPath,
          config.targetFileName,
        );
        await fs.writeFile(targetFilePath, processedContent, 'utf8');
    
        if (config.specialHandling === 'roocode') {
          const sourceJsonPath = path.join(
            this.templatesPath,
            'custom-mode.json',
          );
          const targetJsonPath = path.join(projectRoot, '.roomodes');
          await fs.copyFile(sourceJsonPath, targetJsonPath);
        }
    
        if (config.specialHandling === 'kilocode') {
          const sourceJsonPath = path.join(
            this.templatesPath,
            'custom-mode.json',
          );
          const targetJsonPath = path.join(projectRoot, '.kilocodemodes');
          await fs.copyFile(sourceJsonPath, targetJsonPath);
        }
    
        return {
          success: true,
          message: `Successfully deployed Anubis rules for ${config.name}`,
          targetFile: targetFilePath,
        };
      } catch (error) {
        return {
          success: false,
          message: `Failed to deploy rules for ${config.name}: ${error.message}`,
        };
      }
    }
  • NestJS module that provides and exports InitRulesMcpService (containing the MCP tool) and InitRulesService.
    @Module({
      providers: [InitRulesService, InitRulesMcpService],
      exports: [InitRulesService, InitRulesMcpService],
    })
    export class InitRulesModule {}
  • Configuration object defining supported AI agents, their templates, target paths, and special handling.
    private readonly agentConfigs: Record<string, AIAgentConfig> = {
      cursor: {
        name: 'Cursor IDE',
        sourceTemplate: 'workflow-protocol-function-calls.md',
        targetPath: '.cursor/rules',
        targetFileName: '000-workflow-core.mdc',
        requiresFrontmatter: true,
        ensureDirectories: ['.cursor', '.cursor/rules'],
      },
      copilot: {
        name: 'GitHub Copilot',
        sourceTemplate: 'workflow-protocol-function-calls.md',
        targetPath: '.github',
        targetFileName: 'copilot-instructions.md',
        requiresFrontmatter: false,
        ensureDirectories: ['.github'],
      },
      roocode: {
        name: 'RooCode',
        sourceTemplate: 'workflow-protocol-xml.md',
        targetPath: '.roo/rules-anubis',
        targetFileName: 'rules.md',
        requiresFrontmatter: false, // XML file doesn't need frontmatter
        ensureDirectories: ['.roo', '.roo/rules-anubis'],
        specialHandling: 'roocode', // Add special flag
      },
      kilocode: {
        name: 'KiloCode',
        sourceTemplate: 'workflow-protocol-xml.md',
        targetPath: '.kilocode/rules-anubis',
        targetFileName: 'rules.md',
        requiresFrontmatter: false, // XML file doesn't need frontmatter
        ensureDirectories: ['.kilocode', '.kilocode/rules-anubis'],
        specialHandling: 'kilocode', // Add special flag
      },
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Initialize' but doesn't clarify if this is a one-time setup, what happens to existing rules, whether it requires specific permissions, or what the expected outcome is (e.g., success confirmation or error handling). This leaves critical behavioral traits undefined for a tool that likely modifies system state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action and target. It avoids redundancy and wastes no words, making it easy to parse quickly. Every element ('Initialize', 'Anubis workflow rules', 'specified AI agent') contributes directly to understanding the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a tool that likely involves system configuration (implied by 'Initialize'), the description is incomplete. It lacks details on behavioral outcomes, error conditions, or dependencies with siblings like 'bootstrap_workflow'. For a tool with potential state changes and multiple related operations, more context is needed to guide safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with clear descriptions for both parameters, including an enum for 'agentName' and a default for 'projectRoot'. The description adds minimal value beyond the schema by specifying 'AI agent to deploy rules for' in the description text, but it doesn't provide additional context like agent capabilities or project root implications. Baseline 3 is appropriate as the schema adequately documents parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Initialize') and the resource ('Anubis workflow rules'), specifying the target ('to specified AI agent'). It distinguishes the tool's purpose from siblings like 'bootstrap_workflow' or 'execute_transition' by focusing on rule initialization rather than execution or setup. However, it doesn't explicitly differentiate from all siblings, such as 'get_workflow_guidance', which might involve rules indirectly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions the target AI agents but doesn't specify prerequisites, timing (e.g., after bootstrapping), or exclusions. Siblings like 'bootstrap_workflow' or 'execute_transition' suggest related operations, but no explicit comparison or usage context is given, leaving the agent to infer based on tool names alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/Hive-Academy/Anubis-MCP'

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