- Home
- MCP servers
- PHPStan
PHPStan
- 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-phpstan-server": {
"command": "/absolute/path/to/mcp/phpstan-server/bin/mcp-phpstan",
"args": [],
"env": {
"MCP_PHPSTAN_PATH": "/usr/local/bin/phpstan",
"MCP_PHPSTAN_LEVEL": "max",
"MCP_PHPSTAN_CONFIG": "/path/to/your/phpstan.neon"
}
}
}
}You run a lightweight MCP server in pure PHP that exposes two debugging tools for PHPStan: a standard analyze tool and a Pro JSON output tool. This server runs locally, has no Composer dependencies, and is designed to be dropped into your project to provide on-demand code analysis through a consistent MCP interface.
How to use
Start the MCP PHPStan server in your environment and connect to it with an MCP client. The server speaks JSON-RPC over STDIN/STDOUT, so your client should send initialization, tool listing, and tool calls, then receive structured results from the running process.
How to install
Prerequisites: you need PHP available on your system to run the MCP server. You do not need Composer for this server.
- Make the MCP server executable. Run this in your terminal where the server is located.
chmod +x mcp/phpstan-server/bin/mcp-phpstan
```json
{
"mcpServers": {
"phpstan": {
"command": "/absolute/path/to/mcp/phpstan-server/bin/mcp-phpstan",
"env": {
"MCP_PHPSTAN_PATH": "/usr/local/bin/phpstan",
"MCP_PHPSTAN_CONFIG": "/path/to/your/phpstan.neon",
"MCP_PHPSTAN_LEVEL": "max"
}
}
}
}
Additional setup notes
Configure how your MCP client starts and connects to the server by pointing it to the exact executable path shown above. You can also override PHPStan configuration and analysis level through environment variables.
Configuration and environment
Environment variables you can set to customize the server behavior include those listed below. The server will read these values when it starts to tailor PHPStan execution for your project.
-
MCP_PHPSTAN_PATH: path to the phpstan binary (default: vendor/bin/phpstan then phpstan on PATH)
-
MCP_PHPSTAN_CONFIG: path to a phpstan.neon or phpstan.neon.dist (optional; autodetected upward)
-
MCP_PHPSTAN_LEVEL: the level to pass to phpstan (e.g. max or 8) if not set in config
Notes and troubleshooting
If no config file is provided, the server searches upward from the current working directory for phpstan.neon or phpstan.neon.dist. Output to STDOUT is strictly JSON-RPC messages, while logs go to STDERR. Non-zero phpstan exit codes may indicate findings or failures; the server parses the output to determine error state.
Available tools
phpstan_analyze
Runs PHPStan and returns a readable report.
phpstan_pro
Runs PHPStan Pro JSON output for richer diagnostics when available.