PHPCS

Provides PHP_CodeSniffer and PHP_CodeBeautifier execution through an MCP stdio server.
  • php

0

GitHub Stars

php

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "larspohlmann-mcp-phpcs-server": {
      "command": "/absolute/path/to/mcp/phpcs-server/bin/mcp-phpcs",
      "args": [],
      "env": {
        "MCP_PHPCS_PATH": "/usr/local/bin/phpcs",
        "MCP_PHPCBF_PATH": "/usr/local/bin/phpcbf",
        "MCP_PHPCS_RULESET": "/path/to/your/phpcs.xml"
      }
    }
  }
}

This MCP server lets you run PHP CodeSniffer and PHP Code Beautifier as a lightweight, local service that you can call from an MCP client. It exposes two tools for automated code quality checks and fixes, all without extra dependencies beyond PHP itself.

How to use

You run the MCP server locally as a stdio process and connect to it from your MCP client. The server speaks JSON-RPC over STDIN/STDOUT, exposing two tools: phpcs_check for running PHP_CodeSniffer and returning a readable report, and phpcbf_fix for running PHP Code Beautifier and Fixer. You configure the MCP client to start the server using the explicit startup command shown below, and then you can invoke either tool by name with the required input path.

Key capabilities you can leverage include validating PHP files against a ruleset and automatically fixing non-conforming code where possible. Non-zero exit codes from phpcs indicate violations found in the analyzed file(s). Output is delivered as JSON-RPC messages on STDOUT, while logs appear on STDERR.

How to install

Prerequisites you need on your machine before installing this MCP server: a PHP runtime compatible with your environment. You do not need Composer dependencies for this server.

Make the MCP server executable and ready to run. Ensure you have the path to the server binary or script you will start.

Create a configuration that points to your PHP_CodeSniffer tools and your preferred ruleset location as needed. The server can read environment variables to customize these paths.

Start the server from its runtime location. You will typically run a command similar to the example below by giving the absolute path to the server entry point.

chmod +x mcp/phpcs-server/bin/mcp-phpcs

/absolute/path/to/mcp/phpcs-server/bin/mcp-phpcs

Example configuration for a client

Here is an example MCP client configuration that launches the server and provides environment overrides for the tool paths and ruleset.

{
  "mcpServers": {
    "phpcs": {
      "command": "/absolute/path/to/mcp/phpcs-server/bin/mcp-phpcs",
      "env": {
        "MCP_PHPCS_PATH": "/usr/local/bin/phpcs",
        "MCP_PHPCBF_PATH": "/usr/local/bin/phpcbf",
        "MCP_PHPCS_RULESET": "/path/to/your/phpcs.xml"
      }
    }
  }
}

Available tools

phpcs_check

Runs PHP_CodeSniffer on a given path and returns a readable report. It respects a configured ruleset and reports any violations found.

phpcbf_fix

Runs PHP Code Beautifier and Fixer on a given path to automatically fix coding standard violations where possible.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational