mcpField
M
Mcp Phpcs Server

Mcp Phpcs Server

Local
github.com/larspohlmannDeveloper Tools1Updated 16w ago

About Mcp Phpcs Server

A pure-PHP MCP server for PHP_CodeSniffer, aimed at PHP developers using MCP-compatible clients. It offers code checks and automatic fixes without Composer dependencies.

Key features

  1. 01Check files or directories with phpcs
  2. 02Auto-fix violations with phpcbf
  3. 03Discover coding rulesets
  4. 04Configure binary paths and rulesets

Use cases

  1. 01Review PHP coding-standard violations
  2. 02Fix issues in a PHP project
  3. 03Run checks from an MCP client

MCP support

Exposes `phpcs_check` and `phpcbf_fix` tools to MCP clients over JSON-RPC 2.0 on stdio.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP PHPCS Server

A Model Context Protocol server that brings PHP_CodeSniffer into your AI coding workflow — lint PHP against your coding standard and auto-fix violations, straight from any MCP client.

PHP Dependencies License

Implemented in pure PHP with zero Composer dependencies. Drop it into any project or run it standalone — it speaks JSON-RPC 2.0 over stdio and works with Claude Desktop, Claude Code, Cursor, and any other MCP-compatible client.

Tools

ToolDescription
phpcs_checkRuns PHP_CodeSniffer against a file or directory and returns a readable report of violations.
phpcbf_fixRuns PHP Code Beautifier and Fixer (phpcbf) to automatically fix fixable violations.

Both tools take a single required path (absolute or project-relative file/directory).

Requirements

  • PHP 8.1+
  • phpcs and phpcbf binaries available (via PHP_CodeSniffer, e.g. a project's vendor/bin or a global install)

Quick start

  1. Clone the repository (or copy it into your project):

    git clone https://github.com/larspohlmann/mcp-phpcs-server.git
    
  2. Make the entrypoint executable:

    chmod +x mcp-phpcs-server/bin/mcp-phpcs
    
  3. Register it with your MCP client (see below).

Configuration

Configure via environment variables or config/config.json. Environment variables take precedence.

Variableconfig.json keyDescriptionDefault
MCP_PHPCS_PATHphpcsPathPath to the phpcs binaryphpcs on PATH
MCP_PHPCBF_PATHphpcbfPathPath to the phpcbf binaryphpcbf on PATH
MCP_PHPCS_RULESETrulesetPathPath to a coding-standard rulesetauto-discovered

If no ruleset is provided, the server searches upward from the current working directory for one of phpcs.xml, phpcs.xml.dist, or ruleset.xml.

Client setup

Claude Desktop / Claude Code

Add the server to your MCP config:

{
  "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"
      }
    }
  }
}

Then ask your assistant something like "Run phpcs on src/Service/UserService.php and fix what you can."

Example tool call

{
  "name": "phpcs_check",
  "arguments": { "path": "src/Service/UserService.php" }
}

Architecture

The server follows a light Domain-Driven Design layout:

  • src/Domain — tool contracts and result value objects
  • src/Application — JSON-RPC MCP server and tool registry
  • src/Infrastructure — process runner, config, ruleset discovery, tool implementations
  • bin/mcp-phpcs — stdio entrypoint

It implements the MCP methods initialize, tools/list, and tools/call.

Notes

  • STDOUT carries only JSON-RPC messages; all logs go to STDERR.
  • A non-zero exit code from phpcs means violations were found — it is reported as findings, not treated as a fatal error.

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.