Skip to main content
Glama

find_vanilla_alternative

Check if your custom DayZ Enforce Script implementation has an existing vanilla function alternative to simplify your code.

Instructions

Check if custom code has vanilla DayZ function alternative

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customCodeYesYour custom implementation

Implementation Reference

  • Zod schema for the find_vanilla_alternative tool input (requires 'customCode' string).
    const FindVanillaAlternativeSchema = z.object({
      customCode: z.string().describe('Custom code that might have vanilla alternative')
    });
  • Registration of the 'find_vanilla_alternative' tool in the tools list (server capability).
      name: 'find_vanilla_alternative',
      description: 'Check if custom code has vanilla DayZ function alternative',
      inputSchema: {
        type: 'object',
        properties: {
          customCode: {
            type: 'string',
            description: 'Your custom implementation'
          }
        },
        required: ['customCode']
      }
    },
  • Handler for the 'find_vanilla_alternative' tool call. Parses arguments, delegates to CodeValidator.validate(), and returns vanilla alternatives.
    case 'find_vanilla_alternative': {
      const args = FindVanillaAlternativeSchema.parse(request.params.arguments);
      
      const result = this.validator.validate(args.customCode);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              customCode: args.customCode,
              alternatives: result.vanillaAlternatives,
              suggestion: result.vanillaAlternatives.length > 0
                ? 'Consider using vanilla functions instead of custom implementation'
                : 'No vanilla alternatives found - custom implementation may be necessary'
            }, null, 2)
          }
        ]
      };
    }
  • Main validate() method in CodeValidator. Called by the handler, runs Iron Rules checks and calls checkVanillaPatterns() to populate vanillaAlternatives.
    validate(code: string): ValidationResult {
      const errors: ValidationError[] = [];
      const suggestions: string[] = [];
      const vanillaAlternatives: { customCode: string; vanillaFunction: string; }[] = [];
    
      // Tokenize for context
      const tokens = lex(code);
    
      // Check Iron Rules
      for (const rule of CodeValidator.ironRules) {
        const error = rule.check(code, tokens);
        if (error) {
          errors.push(error);
        }
      }
    
      // Check for common patterns that could use vanilla functions
      const patterns = this.checkVanillaPatterns(code);
      vanillaAlternatives.push(...patterns);
    
      // Additional suggestions based on code analysis
      if (/for\s*\(\s*int\s+i\s*=\s*0/.test(code) && /GetInventory\(\)/.test(code)) {
        suggestions.push('Consider using GetInventory().EnumerateInventory() instead of manual iteration');
      }
    
      if (/vector\.Distance/.test(code)) {
        suggestions.push('vector.Distance() is available for distance calculations');
      }
    
      if (/GetGame\(\)\.CreateObject/.test(code) && /GetType\(\)/.test(code)) {
        suggestions.push('Consider using EntityAI.CastTo() for safe casting after spawning');
      }
    
      return {
        valid: errors.length === 0,
        errors,
        suggestions,
        vanillaAlternatives
      };
    }
  • Helper method checkVanillaPatterns() that uses regex heuristics to detect custom code patterns that could be replaced by vanilla DayZ functions.
    private checkVanillaPatterns(code: string): Array<{ customCode: string; vanillaFunction: string; }> {
      const patterns: Array<{ customCode: string; vanillaFunction: string; }> = [];
    
      // Check for manual attachment copying
      if (/for.*Attachments|attachment.*Insert|GetAttachmentFromIndex/.test(code)) {
        patterns.push({
          customCode: 'Manual attachment iteration and copying',
          vanillaFunction: 'EntityAI.CopyOldPropertiesToNew(EntityAI old_item)'
        });
      }
    
      // Check for manual player list building
      if (/array<Man>.*players.*GetWorld\(\).*GetPlayerList/.test(code)) {
        patterns.push({
          customCode: 'Manual player list building',
          vanillaFunction: 'GetGame().GetPlayers(array<Man> players)'
        });
      }
    
      // Check for manual string manipulation
      if (/\.Split\(|\.IndexOf\(|\.Substring\(/.test(code)) {
        patterns.push({
          customCode: 'String parsing/splitting',
          vanillaFunction: 'string.Split(), string.IndexOf(), string.Substring() are built-in'
        });
      }
    
      // Check for manual inventory slot iteration
      if (/for.*GetInventory\(\).*GetCargo/.test(code)) {
        patterns.push({
          customCode: 'Manual inventory slot iteration',
          vanillaFunction: 'GetInventory().EnumerateInventory() or GetInventory().GetCargo()'
        });
      }
    
      // Check for manual health/blood operations
      if (/GetHealth\(""|SetHealth\(""|AddHealth/.test(code)) {
        patterns.push({
          customCode: 'Health manipulation',
          vanillaFunction: 'GetHealth(), SetHealth(), AddHealth(), GetStatBlood()'
        });
      }
    
      return patterns;
    }
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. It does not disclose whether the tool is read-only, what side effects exist, or any constraints. The action 'check' implies a read operation, but this is not explicitly stated.

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

Conciseness4/5

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

The description is a single, short sentence with no redundant information. It is concise, though it could be slightly more informative without losing brevity.

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 the simple input schema and lack of output schema, the description is minimal. It fails to explain what constitutes a 'vanilla alternative', the expected format of customCode, or the nature of the response, leaving the agent underinformed.

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% for the single parameter 'customCode', with a basic description 'Your custom implementation'. The tool description adds no additional semantic value beyond the schema, achieving the baseline of 3.

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 uses the verb 'check' with the resource 'custom code' and the goal 'vanilla DayZ function alternative', clearly stating what the tool does. It distinguishes itself from sibling tools like find_callers and find_usage_examples, but does not specify the output format.

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, nor any exclusions or prerequisites. The agent is left without context on appropriate usage scenarios.

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

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/quantumloader/dayz-api-mcp-server'

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