Skip to main content
Glama
miniOrangeDev

WordPress Code Review MCP Server

validate_code

Validate PHP, JavaScript, CSS, or HTML code against WordPress coding standards to ensure compliance and maintain code quality in development projects.

Instructions

Validate code against configured coding standards

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesThe code to validate
languageYesThe programming language of the code

Implementation Reference

  • Primary MCP tool handler for 'validate_code': delegates to guidelineSource.validateCode and formats the response with issues and suggestions.
    private async validateCode(code: string, language: string) {
      try {
        const result = await this.guidelineSource.validateCode(code, language);
        
        const response = [];
        
        if (result.issues.length > 0) {
          response.push(`❌ **Issues Found:**\n${result.issues.map(issue => `- ${issue}`).join('\n')}`);
        }
        
        if (result.suggestions.length > 0) {
          response.push(`💡 **Suggestions:**\n${result.suggestions.map(suggestion => `- ${suggestion}`).join('\n')}`);
        }
        
        if (response.length === 0) {
          response.push('✅ Code validation passed. No issues detected.');
        }
        
        return {
          content: [
            {
              type: 'text',
              text: response.join('\n\n'),
            },
          ],
        };
      } catch (error) {
        throw new Error(`Code validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
  • Registration of the 'validate_code' tool in getTools(), including name, description, and input schema.
    {
      name: 'validate_code',
      description: 'Validate code against configured coding standards',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: 'The code to validate',
          },
          language: {
            type: 'string',
            enum: ['php', 'javascript', 'css', 'html'],
            description: 'The programming language of the code',
          },
        },
        required: ['code', 'language'],
      },
    },
  • Core validation handler: extracts rules from guidelines markdown and applies them to the provided code.
    private parseValidationRules(guidelines: string, code: string, language: string): { issues: string[]; suggestions: string[] } {
      const issues: string[] = [];
      const suggestions: string[] = [];
    
      // Parse markdown format guidelines and apply to code
      const rules = this.extractRules(guidelines, 'VALIDATION_RULES');
      
      for (const rule of rules) {
        const result = this.applyRule(rule, code, language);
        if (result.violation) {
          issues.push(result.message);
        } else if (result.suggestion) {
          suggestions.push(result.message);
        }
      }
    
      return { issues, suggestions };
    }
  • GuidelineSource.validateCode implementation: loads validation rules and invokes parsing logic.
    async validateCode(code: string, language: string): Promise<{ issues: string[]; suggestions: string[] }> {
      const guidelines = await this.fetchGuidelines('validation-rules');
      return this.parseValidationRules(guidelines, code, language);
    }
  • Helper function to extract validation rules from the fetched guidelines markdown content.
    private extractRules(content: string, section: string): Array<{ pattern: string; message: string; level?: string; language?: string }> {
      const rules: Array<{ pattern: string; message: string; level?: string; language?: string }> = [];
      
      // Look for rules in markdown format - simplified approach
      const sectionRegex = new RegExp(`## ${section}([\\s\\S]*)`, 'i');
      const sectionMatch = content.match(sectionRegex);
      
      if (sectionMatch) {
        // Split by lines and process each line that looks like a rule
        const lines = sectionMatch[1].split('\n');
        
        for (const line of lines) {
          // Look for lines that start with - **Pattern**:
          if (line.trim().startsWith('- **Pattern**:')) {
            // Extract pattern
            const patternMatch = line.match(/`([^`]+)`/);
            if (!patternMatch) continue;
            
            const pattern = patternMatch[1];
            
            // Extract message (everything between **Message**: and **Level**: or **Language**:)
            const messageMatch = line.match(/\*\*Message\*\*:\s*([^*]+?)(?:\s*\*\*(?:Level|Language)\*\*|$)/);
            const message = messageMatch ? messageMatch[1].trim() : 'No message';
            
            // Extract level
            const levelMatch = line.match(/\*\*Level\*\*:\s*(\w+)/);
            const level = levelMatch ? levelMatch[1] : 'INFO';
            
            // Extract language
            const languageMatch = line.match(/\*\*Language\*\*:\s*(\w+)/);
            const language = languageMatch ? languageMatch[1] : 'all';
            
            rules.push({
              pattern,
              message,
              level,
              language
            });
          }
        }
      }
      
      return rules;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool validates code but doesn't disclose behavioral traits such as what happens during validation (e.g., returns errors/warnings, requires authentication, has rate limits, or whether it's read-only vs. mutating). The description is minimal and lacks essential context for safe and effective use.

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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration. Every word earns its place.

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 tool's complexity (validation against standards) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the validation returns (e.g., errors, success status), behavioral constraints, or how it interacts with siblings. For a tool with no structured support, more detail is needed to guide the agent effectively.

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%, so the schema fully documents both parameters ('code' and 'language') with descriptions and an enum for 'language'. The description adds no additional meaning beyond what the schema provides, such as format details for 'code' or how 'language' affects validation. Baseline is 3 when schema does the heavy lifting.

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 tool's purpose with a specific verb ('validate') and resource ('code'), specifying it validates against 'configured coding standards'. It distinguishes from 'get_guidelines' (which likely retrieves standards) and 'security_check' (which likely focuses on security rather than general coding standards). However, it doesn't explicitly mention how it differs from siblings beyond the general domain.

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 like 'get_guidelines' or 'security_check'. It doesn't specify prerequisites (e.g., whether standards must be pre-configured), exclusions, or typical use cases. Usage is implied from the purpose but not explicitly stated.

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/miniOrangeDev/wp-code-review-mcp-server'

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