MCP PHPCS Server

MCP PHPCS Server

mcp-phpcs-server•bylarspohlmann

A Model Context Protocol server implemented in pure PHP that runs PHP_CodeSniffer against PHP files or directories, reports violations, and auto-fixes fixable issues from any MCP client.

License: MIT•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Provides a phpcs_check tool that runs PHP_CodeSniffer against a file or directory and returns a readable report of violations.
  • •Provides a phpcbf_fix tool that runs PHP Code Beautifier and Fixer to automatically fix fixable violations.
  • •Both tools take a single required path pointing to an absolute or project-relative file or directory.
  • •If no ruleset is configured, the server searches upward from the working directory for phpcs.xml, phpcs.xml.dist, or ruleset.xml.

BEST FOR

  • •Asking an AI assistant to lint a specific PHP file and fix what it can within an MCP client.
  • •Enforcing a project's coding standard through tools that respect configured or auto-discovered rulesets.

ABOUT MCP-PHPCS-SERVER

MCP PHPCS Server is cataloged as an MCP server attributed to larspohlmann. A Model Context Protocol server implemented in pure PHP that runs PHP_CodeSniffer against PHP files or directories, reports violations, and auto-fixes fixable issues from any MCP client. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for MCP PHPCS Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does a non-zero exit code from phpcs cause the server to fail?

No. A non-zero exit code from phpcs means violations were found, and the server reports them as findings rather than treating them as a fatal error.

How does the server separate its logs from JSON-RPC messages?

STDOUT carries only JSON-RPC messages, and all logs are written to STDERR.

Upstream README

View this exact version on GitHub

README.md · b2abf0862331 · Fetched 2026-11-13 10:55:10 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

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

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for MCP PHPCS Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-phpcs-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools