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 with best practices and maintain code quality.

Instructions

Validate code against configured coding standards

Input Schema

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

Implementation Reference

  • Registration of the 'validate_code' tool in GuidelinesManager.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'], }, },
  • Input schema (JSON Schema) for the validate_code tool defining required parameters 'code' and 'language'.
    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'], },
  • Primary handler for validate_code tool: invokes guidelineSource.validateCode, formats results (issues/suggestions) into MCP text response.
    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'}`); } }
  • validateCode implementation in UrlGuidelineSource: fetches validation rules and delegates to parseValidationRules.
    async validateCode(code: string, language: string): Promise<{ issues: string[]; suggestions: string[] }> { const guidelines = await this.fetchGuidelines('validation-rules'); return this.parseValidationRules(guidelines, code, language); }
  • Core helper function parseValidationRules: extracts rules from guidelines markdown, applies each rule to code, collects 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 }; }

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

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