Skip to main content
Glama
miniOrangeDev

WordPress Code Review MCP Server

validate_code

Validates code in PHP, JavaScript, CSS, or HTML against configured coding standards.

Instructions

Validate code against configured coding standards

Input Schema

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

Implementation Reference

  • Tool registration: 'validate_code' is defined with name, description, and inputSchema (requires 'code' and 'language' with language enum of php, javascript, css, html).
    {
      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'],
      },
    },
  • Handler: The private method validateCode in GuidelinesManager delegates to the guidelineSource.validateCode() and formats the result into issues/suggestions or a pass message.
    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'}`);
      }
    }
  • Helper: UrlGuidelineSource.validateCode fetches validation-rules guidelines and then parses them against the provided code and language.
    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: Parses validation rules from markdown guidelines, extracts rules under 'VALIDATION_RULES' section, and applies each rule to the code, collecting issues and suggestions.
    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 };
    }
  • Schema: The GuidelineSource interface defines the contract for validateCode, returning an object with issues (string[]) and suggestions (string[]).
    export interface GuidelineSource {
      fetchGuidelines(category?: string): Promise<string>;
      validateCode(code: string, language: string): Promise<{ issues: string[]; suggestions: string[] }>;
      performSecurityCheck(code: string): Promise<{ vulnerabilities: string[]; warnings: string[]; recommendations: string[] }>;
    }
Behavior2/5

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

Without annotations, the description carries full responsibility for behavioral disclosure, but it only states what the tool does, not how it behaves (e.g., side effects, return format, errors).

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 sentence, very concise. While it could be expanded slightly, it contains no unnecessary words and is well-structured for its 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 no annotations, no output schema, and only two parameters, the description lacks complete context. It does not explain 'configured coding standards,' how results are returned, or error handling.

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?

The input schema already describes both parameters fully (100% coverage). The description adds no additional meaning beyond the schema, so a baseline score of 3 is appropriate.

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

Purpose5/5

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

The description clearly states the action ('Validate code') and the resource ('against configured coding standards'), effectively distinguishing it from siblings like get_guidelines and security_check.

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?

No guidance is provided on when to use this tool versus its siblings (get_guidelines, security_check). The description does not mention alternatives or contexts.

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