Provides pre-commit workflow integration for checking staged PHP files, auto-fixing violations, and re-staging files before commits, with the ability to block commits when coding standard errors are found.
Enables automatic WordPress Coding Standards (WPCS) validation and auto-fixing for WordPress plugins and themes, including pre-commit checks, individual file/directory scanning, and integration with WordPress coding standards rulesets (WordPress-Core, WordPress-Extra, WordPress-Docs).
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@WPCS MCP Servercheck my plugin's main PHP file for WPCS violations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
WPCS MCP Server
A Model Context Protocol (MCP) server that integrates WordPress Coding Standards (WPCS) with Claude AI. Automatically check and fix your WordPress plugin/theme code to meet WordPress.org standards.
Don't use Claude AI? No problem! See GIT-HOOKS-SETUP.md for standalone Git hooks, GitHub Actions, and CI/CD setup.
One-Line Install (Git Hooks Only)
For automatic WPCS checks on every commit without Claude AI:
This installs phpcs + WPCS + PHPCompatibility and sets up pre-commit hooks in your current repo.
Why Use This?
If you're developing WordPress plugins or themes, your code must follow WordPress Coding Standards to:
✅ Get approved on WordPress.org plugin/theme directory
✅ Write consistent, readable code
✅ Follow security best practices
✅ Make your code maintainable
This MCP server lets Claude AI automatically check and fix your PHP code against WPCS before you commit.
Requirements Checklist
Before installing, ensure you have all requirements:
Requirement | Minimum Version | Check Command | Install Guide |
Node.js | 18+ |
| |
PHP | 8.2+ |
| See PHP Setup below |
Composer | 2.0+ |
| |
Claude Desktop or Claude Code | Latest |
|
PHP Setup by Platform
Quick Start
Step 1: Clone & Build
Important: Use
npm install --include=devto ensure TypeScript compiler is available for building.
Step 2: Install WPCS Dependencies
The server attempts auto-install, but for reliability, install manually:
Step 3: Configure MCP Server
Choose your setup method:
Configuration Options
For Claude Code CLI (Recommended)
Option A: Using CLI Command (Global)
Then manually add the PATH environment in ~/.claude.json:
Option B: Manual Configuration (Global)
Add to ~/.claude.json under the mcpServers key at root level:
Option C: Project-Level Configuration
Add to ~/.claude.json under a specific project:
For Claude Desktop
macOS - Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
Windows - Edit %APPDATA%\Claude\claude_desktop_config.json:
PATH Configuration by Setup
Choose the correct PATH based on your PHP installation:
PHP Setup | PATH Value |
Herd (macOS) |
|
Homebrew (macOS) |
|
MAMP (macOS) |
|
System PHP (Linux) |
|
Windows |
|
Important: Replace
~with your full home path (e.g.,/Users/yourname) in JSON configs.
Step 4: Verify Installation
Test the Server Manually
Available Tools
Tool | What It Does |
| Most useful! Auto-fix staged files, re-stage, report remaining issues |
| Check all staged PHP files before commit |
| Check a single PHP file |
| Check all PHP files in a directory |
| Auto-fix WPCS violations in a file |
| Check PHP 8.1/8.2/8.3/8.4 compatibility |
Usage Examples
Just ask Claude in natural language:
Typical Workflow
Write your WordPress plugin/theme code
Stage your changes:
git add .Ask Claude: "Run wpcs_pre_commit"
Claude will:
Auto-fix what can be fixed (spacing, formatting, etc.)
Re-stage the fixed files
Report any remaining issues that need manual fixes
Commit your clean code!
What WPCS Checks
The WordPress ruleset includes:
Standard | What It Checks |
WordPress-Core | Naming conventions, spacing, formatting, PHP compatibility |
WordPress-Extra | Discouraged functions, loose comparisons, Yoda conditions |
WordPress-Docs | PHPDoc comments, inline documentation |
Common Issues It Catches:
❌
if($x == true)→ ✅if ( true === $x )❌ Missing spaces in function calls
❌ Using
extract(),eval(),create_function()❌ Missing or incorrect PHPDoc blocks
❌ Incorrect text domain in translations
❌ Direct database queries without preparation
PHP Compatibility Checking
Check if your code works with PHP 8.1, 8.2, 8.3, and 8.4:
What It Detects:
Issue Type | Example |
Removed Functions |
|
Deprecated Features |
|
New Syntax | Named arguments require PHP 8.0+ |
Type Changes | Return type changes in built-in functions |
Removed Constants |
|
Version Examples:
WordPress.org requires PHP 7.4+ minimum, so use "7.4-" to ensure broad compatibility.
Add Tool Permissions (Claude Code)
Add to ~/.claude/settings.json:
Optional: Auto-Check Before Commits
Add a Claude Code hook to automatically check WPCS before every commit.
Create ~/.claude/hooks/wpcs-pre-commit.sh:
Add to ~/.claude/settings.json:
Troubleshooting
"Failed to connect" in claude mcp list
Most common cause: Wrong PHP version in PATH.
Fix: Update the PATH in your MCP config to include your PHP 8.2+ binary directory FIRST.
"phpcs not found"
"WordPress standard not found"
Build fails with "tsc: command not found"
"Auto-install failed" on server startup
This happens when:
PHP version is too old (need 8.2+)
Composer version is too old (need 2.0+)
Network issues
Fix: Install dependencies manually (see Step 2 above).
MCP server not loading in Claude Desktop
Verify the path in your config uses absolute paths (no
~)Ensure you ran
npm run buildRestart Claude Desktop completely (quit and reopen)
Check the path exists:
ls -la ~/.mcp-servers/wpcs-mcp-server/build/index.js
Development
Complete Setup Checklist
Use this checklist to ensure everything is configured correctly:
Node.js 18+ installed (
node -v)PHP 8.2+ installed and in PATH (
php -v)Composer 2.0+ installed (
composer -V)Repository cloned to
~/.mcp-servers/wpcs-mcp-serverBuilt with dev dependencies (
npm install --include=dev && npm run build)WPCS installed globally via Composer
phpcs shows WordPress standards (
~/.composer/vendor/bin/phpcs -i)MCP config added to
~/.claude.jsonor Claude Desktop configPATH includes PHP binary directory in MCP env config
PATH includes composer/vendor/bin in MCP env config
Server shows Connected (
claude mcp list)
License
GPL-2.0-or-later
Author
Varun Dubey (@vapvarun)
Website: wbcomdesigns.com
Email: varun@wbcomdesigns.com
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.