WPCS MCP Server
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).
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
WPCS MCP Server
A Model Context Protocol (MCP) server that puts the WordPress static-standards toolchain behind an AI assistant: PHP lint, PHP compatibility, WordPress Coding Standards (phpcs/WPCS), PHPStan, and project/readme validation - run against any plugin or theme on demand. It is a thin, honest wrapper over the real tools (it drives phpcs/phpcbf/PHPCompatibilityWP/phpstan and respects a project's own .phpcs.xml.dist / phpstan.neon), not a regex re-implementation.
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:
curl -sSL https://raw.githubusercontent.com/vapvarun/wpcs-mcp-server/main/scripts/install-hooks.sh | bashThis installs phpcs + WPCS + PHPCompatibility and sets up pre-commit hooks in your current repo.
Related MCP server: claudaborative-editing
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
# Herd installs PHP at:
# ~/Library/Application Support/Herd/bin/php
# Verify Herd PHP
~/Library/Application\ Support/Herd/bin/php -v
# Should show PHP 8.2+
# Herd also provides Composer at:
# ~/Library/Application Support/Herd/bin/composer# Install PHP 8.4
brew install php@8.4
# Add to PATH in ~/.zshrc
export PATH="/opt/homebrew/opt/php@8.4/bin:$PATH"
# Verify
php -v# MAMP PHP location
/Applications/MAMP/bin/php/php8.2.x/bin/php
# Add to PATH in ~/.zshrc
export PATH="/Applications/MAMP/bin/php/php8.2.x/bin:$PATH"# Install via Chocolatey
choco install php --version=8.4
# Or download from php.net and add to PATHsudo apt update
sudo apt install php8.2 php8.2-cli composerQuick Start
Step 1: Clone & Build
git clone https://github.com/vapvarun/wpcs-mcp-server.git ~/.mcp-servers/wpcs-mcp-server
cd ~/.mcp-servers/wpcs-mcp-server
npm install --include=dev && npm run buildImportant: 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:
# Allow the composer installer plugin
composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
# Install phpcs, WPCS, and PHPCompatibility
composer global require squizlabs/php_codesniffer wp-coding-standards/wpcs phpcompatibility/phpcompatibility-wp dealerdirect/phpcodesniffer-composer-installer
# Verify installation
~/.composer/vendor/bin/phpcs -i
# Should show: WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra, PHPCompatibility, PHPCompatibilityWPStep 3: Configure MCP Server
Choose your setup method:
Configuration Options
For Claude Code CLI (Recommended)
Option A: Using CLI Command (Global)
claude mcp add wpcs --scope user -- node ~/.mcp-servers/wpcs-mcp-server/build/index.jsThen manually add the PATH environment in ~/.claude.json:
{
"mcpServers": {
"wpcs": {
"type": "stdio",
"command": "node",
"args": ["/Users/YOUR_USERNAME/.mcp-servers/wpcs-mcp-server/build/index.js"],
"env": {
"PATH": "/Users/YOUR_USERNAME/Library/Application Support/Herd/bin:/Users/YOUR_USERNAME/.composer/vendor/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}Option B: Manual Configuration (Global)
Add to ~/.claude.json under the mcpServers key at root level:
{
"mcpServers": {
"wpcs": {
"type": "stdio",
"command": "node",
"args": ["/Users/YOUR_USERNAME/.mcp-servers/wpcs-mcp-server/build/index.js"],
"env": {
"PATH": "/Users/YOUR_USERNAME/Library/Application Support/Herd/bin:/Users/YOUR_USERNAME/.composer/vendor/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}Option C: Project-Level Configuration
Add to ~/.claude.json under a specific project:
{
"projects": {
"/path/to/your/wordpress-project": {
"mcpServers": {
"wpcs": {
"type": "stdio",
"command": "node",
"args": ["/Users/YOUR_USERNAME/.mcp-servers/wpcs-mcp-server/build/index.js"],
"env": {
"PATH": "/Users/YOUR_USERNAME/Library/Application Support/Herd/bin:/Users/YOUR_USERNAME/.composer/vendor/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}
}
}For Claude Desktop
macOS - Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"wpcs": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/.mcp-servers/wpcs-mcp-server/build/index.js"],
"env": {
"PATH": "/Users/YOUR_USERNAME/Library/Application Support/Herd/bin:/Users/YOUR_USERNAME/.composer/vendor/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
}
}
}
}Windows - Edit %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"wpcs": {
"command": "node",
"args": ["C:\\Users\\YOUR_USERNAME\\.mcp-servers\\wpcs-mcp-server\\build\\index.js"],
"env": {
"PATH": "C:\\php;C:\\Users\\YOUR_USERNAME\\AppData\\Roaming\\Composer\\vendor\\bin;%PATH%"
}
}
}
}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
# Check MCP server status
claude mcp list
# Should show:
# wpcs: node ~/.mcp-servers/wpcs-mcp-server/build/index.js - ✓ ConnectedTest the Server Manually
cd ~/.mcp-servers/wpcs-mcp-server
PATH="YOUR_PHP_PATH:$HOME/.composer/vendor/bin:$PATH" node build/index.js
# Should output:
# Starting WPCS MCP Server...
# phpcs path: /Users/you/.composer/vendor/bin/phpcs
# Available standards: ... WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra, PHPCompatibility ...
# WPCS MCP Server running on stdioAvailable Tools (12)
Check & fix
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 |
Static standards (the release gate, in order)
Tool | What It Does |
| The ordered gate: |
| PHPCompatibilityWP static sniff, default |
| PHPStan at the plugin's own level (uses its vendor binary). Not installed = |
| Headers, readme.txt, text domain, |
Supplementary heuristics (things WPCS/PHPStan do not cover)
Tool | What It Does |
| Hook timing, enqueue placement, hardcoded paths, large files, basic a11y. No security checks: use the wp-security-review skill and Plugin Check |
| HTML/CSS/JS consistency + accessibility heuristics |
| Graded (A-F) report of the two heuristics above |
Where this fits
This server owns static standards. Its sibling, wp-plugin-qa-mcp-server, owns runtime + cross-layer QA (live REST/AJAX, role probing, wiring and contract drift, journeys). One check, one owner - run each once.
Usage Examples
Just ask Claude in natural language:
"Check my staged files for WPCS issues"
"Run wpcs_pre_commit before I commit"
"Fix WPCS issues in includes/class-my-plugin.php"
"Check the entire src/ directory for coding standards"
"Check PHP 8.2 compatibility for my plugin"
"Is my code compatible with PHP 8.1 to 8.5?"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 your code against PHP 8.1 through 8.5 (a static PHPCompatibilityWP sniff):
"Check PHP 8.2 compatibility for src/"
"Is my plugin compatible with PHP 8.1-8.5?"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:
"8.1" → Check for PHP 8.1 compatibility only
"8.2" → Check for PHP 8.2 compatibility only
"8.1-" → Check PHP 8.1 and all newer versions (the default)
"8.1-8.5" → Check PHP 8.1 through 8.5 compatibilityThe supported range for every Wbcom plugin and theme is PHP 8.1-8.5, so the default is "8.1-".
Lint across PHP versions
wpcs_full_check runs php -n -l with every PHP binary it finds: php, plus php8.1 ... php8.5 on PATH or Homebrew's php@8.x. Set WPCS_PHP_BINARIES (comma-separated paths) to choose them yourself. The report says which versions linted; with one binary it says "linted with PHP X only".
Add Tool Permissions (Claude Code)
Add to ~/.claude/settings.json:
{
"permissions": {
"allow": [
"mcp__wpcs__wpcs_check_staged",
"mcp__wpcs__wpcs_check_file",
"mcp__wpcs__wpcs_check_directory",
"mcp__wpcs__wpcs_fix_file",
"mcp__wpcs__wpcs_pre_commit",
"mcp__wpcs__wpcs_check_php_compatibility"
]
}
}Optional: Auto-Check Before Commits
Add a Claude Code hook to automatically check WPCS before every commit.
Create ~/.claude/hooks/wpcs-pre-commit.sh:
#!/bin/bash
export PATH="$HOME/.composer/vendor/bin:$PATH"
STAGED_PHP=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$' || true)
if [ -z "$STAGED_PHP" ]; then
exit 0
fi
PHP_COUNT=$(echo "$STAGED_PHP" | wc -l | tr -d ' ')
echo "WPCS: Found $PHP_COUNT staged PHP file(s). Run wpcs_pre_commit to check."
exit 0Add to ~/.claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash(git commit*)",
"hooks": [
{
"type": "command",
"command": "bash \"$HOME/.claude/hooks/wpcs-pre-commit.sh\""
}
]
}
]
}
}Troubleshooting
"Failed to connect" in claude mcp list
Most common cause: Wrong PHP version in PATH.
# Check which PHP the MCP server sees
cd ~/.mcp-servers/wpcs-mcp-server
PATH="YOUR_CONFIG_PATH" node build/index.js 2>&1 | head -5
# If you see "PHP Fatal error: Composer detected issues... require PHP >= 8.2"
# Your PATH doesn't include PHP 8.2+Fix: Update the PATH in your MCP config to include your PHP 8.2+ binary directory FIRST.
"phpcs not found"
# Install manually
composer global config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer global require squizlabs/php_codesniffer wp-coding-standards/wpcs phpcompatibility/phpcompatibility-wp dealerdirect/phpcodesniffer-composer-installer
# Verify
~/.composer/vendor/bin/phpcs --version"WordPress standard not found"
# Check available standards
~/.composer/vendor/bin/phpcs -i
# If WordPress not listed, reinstall:
composer global remove wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
composer global require wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installerBuild fails with "tsc: command not found"
cd ~/.mcp-servers/wpcs-mcp-server
rm -rf node_modules
npm install --include=dev
npm run build"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
git clone https://github.com/vapvarun/wpcs-mcp-server.git
cd wpcs-mcp-server
npm install --include=dev
npm run build
# Watch mode for development
npm run devComplete 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)
Built by Wbcom Designs
This is one of the internal helper tools we use at Wbcom Designs to keep 100+ WordPress plugins and themes clean across releases - the same static gate that runs on our own products before they ship.
We build community and commerce for WordPress: BuddyPress / BuddyBoss community add-ons, WooCommerce extensions, and the Reign and BuddyX themes. If this tool helps you ship cleaner WordPress code, the products it keeps healthy might help you build your community or store - browse them at wbcomdesigns.com.
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.
Acknowledgments
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
AI code governance and code review for Claude Code, Copilot and Cursor. Checks rules and security.
Manage WordPress blogs and WooCommerce shops from Claude, ChatGPT, Cursor and other MCP apps.
Manage your WordPress site from ChatGPT or Claude: posts, WooCommerce, SEO, images and upkeep.
Read, write, translate and sync WordPress and Webflow blog articles from Claude.
Related MCP Servers
- AlicenseBqualityDmaintenanceConnects Claude to WordPress sites through the REST API, enabling AI-assisted content creation, publishing, media management, user administration, and site maintenance tasks through natural language.4723MIT
- AlicenseNot gradedqualityBmaintenanceEnables real-time AI editing assistance in the WordPress block editor, allowing Claude to proofread, review, edit, translate, compose, and prepare posts for publishing.20 npm21GPL 2.0
- FlicenseNot gradedqualityFmaintenanceIntegrates with Claude Code to execute AI-powered code analysis and workflow automation, supporting pre-defined scenarios like code review and security audit.5-
- AlicenseNot gradedqualityDmaintenanceEnables Claude-powered pre-push code review, blocking bad commits by analyzing diffs with Anthropic's models.1MIT