phpustik MCP Server
Enables AI assistants to deeply interact with the PHP ecosystem, including runtime, static analysis, security scanning, testing, Composer, and frameworks like Laravel and Symfony. It exposes over 30 tools, 8 resources, and 7 prompts via MCP, allowing natural language commands to run PHP linting, static analysis, audits, tests, and project initialization.
README
<div align="center">
π phpustik β MCP Server for PHP
AI'nin PHP gΓΆzΓΌ, kulaΔΔ± ve eli olacak.
MCP Sunucusu Β· Tek npx ile AI asistanΔ±nΔ±za PHP runtime, statik analiz, gΓΌvenlik taramasΔ±, test koΕucusu, Composer ve framework entegrasyonu kazandΔ±rΔ±r.
π·οΈ MCP Server | PHP Tools | AI Integration | Static Analysis | Composer | Laravel | Symfony
"The bridge between AI assistants and the PHP ecosystem."
Production-grade MCP server that gives AI assistants deep visibility into the entire PHP ecosystem β runtime, linting, static analysis, security, testing, Composer and framework tools.
Works with Claude Desktop, Cursor, Claude Code, Opencode, Cline and any MCP-compatible client.
A Model Context Protocol server for PHP β written in TypeScript, shipped as a single
npx-able package, battle-tested on Windows, macOS and Linux.
π― Vision: Make every AI assistant a PHP expert β no Config, no Setup, justnpx phpustik.
Features Β· Installation Β· Usage Β· Tools Β· Resources Β· Prompts Β· Integrations
</div>
π Table of contents
- Why phpustik?
- What's inside
- Features
- Architecture
- Prerequisites
- Installation
- Usage
- Tools β 31 tools in 9 categories
- Resources β 8 read-only data sources
- Prompts β 7 pre-baked workflows
- Integrations
- Configuration
- Troubleshooting
- Security
- Roadmap
- Contributing
- License
π‘ Why phpustik?
AI assistants like Cursor, Claude Desktop, Claude Code and Opencode are increasingly good at writing PHP, but they remain blind to the runtime they target:
- They don't know which PHP version is installed.
- They cannot run
php -lto catch a missing semicolon. - They cannot invoke PHPStan, Psalm, PHP-CS-Fixer, PHPUnit, Rector, PHPMD, PHPCSβ¦
- They cannot manage Composer packages, audit security, or detect the framework.
- They cannot run Laravel artisan or Symfony console commands.
phpustik closes that gap. It is a self-contained MCP server that exposes 31 tools, 8 resources and 7 prompts to the model β across runtime, static analysis, security, testing, refactoring, dependency management and framework integration.
It is:
- Production-ready β strict TypeScript, no
any, exhaustive error handling, structured logs. - Cross-platform β Windows, macOS, Linux, WSL. Path handling is normalised centrally.
- Safe by default β
execFile(no shell), deterministic timeouts, output capping,isError: trueon every failure. - Honest β if a binary is missing, the model is told exactly which command to run.
π¦ What's inside
| Category | Count | Examples |
|---|---|---|
| π Tools | 33 | get_php_info, analyze_php_code, composer_audit, scan_secrets, laravel_routes, phpustik_doctor, phpustik_init |
| π Resources | 8 | php://info, phpustik://workspace, phpustik://composer-json |
| π¬ Prompts | 7 | review_php_code, security_audit, upgrade_php |
| π§° PHP tools wired | 11 | PHP, Composer, PHPStan, Psalm, PHPMD, PHPCS, PHPMND, Rector, PHP Insights, PHPCPD, PHPUnit |
| π Killer features | 2 | phpustik_doctor (one-shot health check) + phpustik_init (project bootstrap) |
| π‘ MCP v2 features | 3 | Logging notifications, progress reporting, cancellation |
β¨ Features
| Area | What you get |
|---|---|
| MCP protocol | Implements McpServer with the v2 high-level registerTool API. |
| Transport | StdioServerTransport for first-class integration with every major MCP client. |
| Validation | Zod v4 input validation on every tool β invalid calls are rejected before any IO. |
| MCP logging | Real-time notifications/message updates while long tools run. |
| Progress | notifications/progress for multi-step operations (phpustik_doctor, phpustik_init). |
| Cancellation | AbortSignal-aware; long ops are tracked and can be killed if the user cancels. |
| Structured output | structuredContent on key tools β model iterates typed data, not Markdown tables. |
| Error UX | Friendly, actionable messages for missing binaries, timeouts, permission errors. |
| Cross-platform | POSIX, Windows, UNC, WSL, file:// and ~-prefixed paths accepted and normalised. |
| Security | No shell: true, no eval, capped output buffers, secrets never logged. |
| Observability | Stderr-only logger with PHPUSTIK_LOG_LEVEL (debug/info/warn/error). |
| Workspace-aware | Auto-detects project root from composer.json / phpstan.neon / artisan / bin/console. |
| Framework-aware | Auto-detects Laravel, Symfony, WordPress, CodeIgniter, Yii, Slim, Laminas, Phalcon, CakePHP. |
| Caching | TTL cache for expensive ops (composer info, phpstan, audits) β 60 s default. |
| Distribution | bin field + files whitelist β npm i -g phpustik or npx phpustik. |
| CI / Release | GitHub Actions matrix (3 OS Γ 3 Node versions), semantic-release. |
π©Ί Killer features
phpustik_doctor β one-shot health check
A single tool call that runs the entire PHP quality pipeline and produces a prioritised Markdown + JSON report.
{
"tool": "phpustik_doctor",
"arguments": {
"category": "all",
"failOn": "high",
"skipTests": false,
"fix": false,
"json": false
}
}
- Runs
composer validate,composer audit,analyze_php_code,run_phpcs,run_phpmd,run_phpunit,scan_secrets,scan_vulnerable_functions,scan_sql_injection,scan_xss,check_php_compatibility,suggest_refactoring,get_php_ini,detect_framework,get_php_infoβ in order, with progress notifications. - Returns a unified Markdown report plus a typed
DoctorReportstructured content (overall status, per-check severity, fixable count, recommendations). failOnlets the model or CI fail at a configurable severity threshold.json: truemode for CI pipelines (returns only the structured content).category: security|quality|styleto run a targeted subset.
phpustik_init β project bootstrap
Generates optimal config files for a PHP project, tailored to its framework and PHP version.
{
"tool": "phpustik_init",
"arguments": {
"dryRun": true,
"force": false,
"phpstanLevel": "5",
"psalmLevel": "4",
"phpVersions": "8.1,8.2,8.3,8.4"
}
}
- Detects
composer.json,composer.lock, framework, PHP version. - Generates up to 11 config files:
phpstan.neon,psalm.xml,.php-cs-fixer.php,rector.php,phpmd.xml,phpcs.xml,phpunit.xml,.editorconfig,.gitattributes,.github/workflows/ci.yml,bin/pre-commit. - All templates hand-tuned for low false-positive rate, modern PHP, PSR-12 + strict types.
dryRun: true(default) shows a unified diff without touching disk.force: trueoverwrites existing files; default is "keep what's there".only: "phpstan.neon,phpunit.xml"restricts to a subset.
π Architecture
ββββββββββββββββββββββββ JSON-RPC over stdio ββββββββββββββββββββββββββββββββββββββββββ
β MCP client β ββββββββββββββββββββββΆ β phpustik server β
β (Cursor / Claude / β β (TypeScript, ESM) β
β Opencode / Cline) β β β
ββββββββββββββββββββββββ β 33 tools β 8 resources β 7 prompts β
ββββββββββββββββββββ¬ββββββββββββββββββββββ
β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββ¬βββ΄ββββββββββββββββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
ββββββββββ ββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββββ ββββββββββββββββ βββββββββββββββ
β php β β composerβ β phpstan / β β phpcs / β β rector / β β laravel / β β pattern β
β -v -m β β * β β psalm / β β phpmd / β β insights / β β symfony β β scanner β
β -l -i β β β β phpmnd β β phpcpd β β phpcpd β β console β β (secrets, β
β -r β β β β β β β β β β β β SQLi, XSS) β
ββββββββββ ββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββββ ββββββββββββββββ βββββββββββββββ
Source layout
src/
βββ index.ts # entry point
βββ server.ts # bootstrap (tools + resources + prompts)
βββ constants.ts # binary names, install hints, timeouts
βββ prompts.ts # 7 MCP prompts
βββ resources.ts # 8 MCP resources
βββ tools/
β βββ get-php-info.ts
β βββ lint-php-file.ts
β βββ analyze-php-code.ts
β βββ format-php-code.ts
β βββ run-php-script.ts
β βββ show-opcache-status.ts
β βββ get-extension-info.ts
β βββ get-php-ini.ts
β βββ check-php-compatibility.ts
β βββ run-phpunit.ts
β βββ run-psalm.ts
β βββ run-phpmd.ts
β βββ run-phpcs.ts
β βββ run-phpmnd.ts
β βββ run-phpcpd.ts
β βββ run-phpinsights.ts
β βββ run-rector.ts
β βββ composer.ts # 9 composer_* tools
β βββ scan-security.ts # 4 scan_* tools
β βββ codegen.ts # add_strict_types, generate_phpdoc, suggest_refactoring
β βββ framework.ts # detect + Laravel + Symfony tools
β βββ doctor.ts # phpustik_doctor
β βββ init.ts # phpustik_init
βββ utils/
βββ executor.ts # execFile wrapper, no shell, timeouts
βββ paths.ts # cross-platform path normalisation
βββ logger.ts # stderr-only structured logger
βββ responses.ts # uniform MCP tool responses
βββ workspace.ts # project root auto-detection
βββ framework-detector.ts
βββ patterns.ts # secrets / SQLi / XSS / vuln-func catalogues
βββ scan-runner.ts # pattern-scan engine
βββ file-scanner.ts # FS walker with skips
βββ cache.ts # TTL cache
βββ active-ops.ts # AbortController registry for cancellation
βββ notification-sink.ts # MCP logging/progress bridge
βββ config-templates.ts # init tool generators
β Prerequisites
| Software | Minimum | Required for |
|---|---|---|
| Node.js | 20.0 LTS | Running the MCP server |
| npm | 10 (bundled) | Package manager (or pnpm/yarn) |
| PHP | 8.0+ | All PHP-runtime tools |
| Composer | 2.x | composer_* tools |
| PHPUnit | 10+ | run_phpunit |
| PHPStan | 1.x or 2.x | analyze_php_code (recommended) |
| Psalm | 5+ | run_psalm |
| PHPMD | 2.x | run_phpmd |
| PHPCS | 3.x | run_phpcs |
| PHPMND | 3.x | run_phpmnd |
| Rector | 1.x | run_rector |
| PHP Insights | 2.x | run_phpinsights |
| PHPCPD | 6+ | run_phpcpd |
| PHP-CS-Fixer | 3.x | format_php_code |
All of these are optional β phpustik will tell you which to install when a tool needs a missing binary.
Quick check
node -v # v20 or higher
php -v # PHP 8.0 or higher
composer --version
π Installation
1. Install PHP
| OS | Command |
|---|---|
| macOS | brew install php |
| Ubuntu/Zorin | sudo apt-get install -y php-cli php-mbstring php-xml |
| Fedora | sudo dnf install -y php-cli |
| Alpine | sudo apk add php php-mbstring |
| Windows | Download from https://windows.php.net/download/ or winget install PHP.PHP.8.3 |
2. Install Composer
# macOS / Linux / WSL
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# Windows (PowerShell)
Invoke-WebRequest https://getcomposer.org/installer -OutFile composer-setup.php
php composer-setup.php
Move-Item composer.phar C:\Program Files\composer\composer.exe
3. Install all PHP tools (optional but recommended)
composer global require \
phpstan/phpstan \
vimeo/psalm \
phpmd/phpmd \
squizlabs/php_codesniffer \
povils/phpmnd \
sebastianbergmann/phpcpd \
nunomaduro/phpinsights \
rector/rector \
friendsofphp/php-cs-fixer \
phpcompatibility/php-compatibility
Make sure ~/.composer/vendor/bin (Linux/macOS) or %USERPROFILE%\Composer\vendor\bin (Windows) is on your PATH.
4. Install phpustik
# Option A: run on demand
npx -y phpustik
# Option B: install globally
npm install -g phpustik
phpustik
π Usage
Quick start with npx
npx -y phpustik
You'll see on stderr:
[INFO] server.boot {"name":"phpustik","version":"1.0.0"}
[INFO] server.php_detected {"version":"PHP 8.3.6 (cli)"}
[INFO] server.ready {"transport":"stdio"}
Local development
git clone https://github.com/halitartuc/phpustik.git
cd phpustik
npm install
npm run dev # tsx, no build
Inspect with the MCP Inspector
npm run inspect
This opens a local web UI where you can call every tool by hand.
π Tools (33)
All tools accept JSON Schema (Zod-validated) input and return MCP text content (and, where useful, a typed structuredContent companion). Tools marked β οΈ are destructive (they modify the filesystem). Tools marked π require project-level configuration.
π PHP Runtime & Environment (5)
| Tool | Purpose |
|---|---|
get_php_info |
PHP sΓΌrΓΌmΓΌ, modΓΌller, INI. |
show_opcache_status |
OPcache + JIT (PHP 8+) durumu. |
get_extension_info |
Tek bir eklentinin fonksiyon/sabit/INI detayΔ±. |
get_php_ini |
Aktif php.ini, tarama dizini, direktifler. |
check_php_compatibility |
PHPCompatibility ile hedef PHP sΓΌrΓΌm denetimi. |
π§ͺ Linting, Formatting & Syntax (4)
| Tool | Purpose |
|---|---|
lint_php_file |
php -l ile sΓΆzdizimi denetimi. |
run_phpcs |
PHP_CodeSniffer (PSR12, Squiz, vb.). fix=true ile otomatik dΓΌzeltme. |
format_php_code |
PHP-CS-Fixer (PSR-12) β dry-run veya apply. |
add_strict_types |
Dosyaya declare(strict_types=1); ekler. |
π Static Analysis (6)
| Tool | Purpose |
|---|---|
analyze_php_code |
PHPStan seviye 0βmax. |
run_psalm |
Psalm seviye 1β8. |
run_phpmd |
Mess Detector (karmaΕΔ±klΔ±k, unused code, design). |
run_phpmnd |
Magic number tespiti. |
run_phpcpd |
Copy-paste tespiti. |
run_phpinsights |
Genel kod kalite skoru (Code / Architecture / Style / Complexity). |
π Refactoring & Codegen (3)
| Tool | Purpose |
|---|---|
run_rector |
Otomatik refactoring β dryRun=true ΓΆnizleme. β οΈ |
generate_phpdoc |
Eksik PHPDoc bloklarΔ±nΔ± raporlar. |
suggest_refactoring |
Uzun metod, god class, derin nesting heuristik ΓΆnerileri. |
βΆοΈ Execution & Testing (2)
| Tool | Purpose |
|---|---|
run_php_script |
Δ°zole temp dosyada PHP kodu Γ§alΔ±ΕtΔ±r. β οΈ |
run_phpunit |
PHPUnit testleri (filter, testdox, coverage). |
π¦ Composer (9)
| Tool | Purpose |
|---|---|
composer_info |
YΓΌklΓΌ paketler / belirli paket bilgisi. |
composer_validate |
composer.json doΔrulama. |
composer_audit |
Bilinen CVE taramasΔ±. |
composer_outdated |
GΓΌncellenmesi gereken paketler. |
composer_require |
Paket ekle. β οΈ |
composer_remove |
Paket kaldΔ±r. β οΈ |
composer_install |
composer install. β οΈ |
composer_update |
composer update. β οΈ |
composer_dump_autoload |
composer dump-autoload. |
π Security (4)
| Tool | Purpose |
|---|---|
scan_secrets |
Hardcoded API key, private key, token, basic-auth URL. |
scan_vulnerable_functions |
eval(), system(), unserialize(), weak hash, extract(). |
scan_sql_injection |
Query string concatenation, whereRaw, DB::statement. |
scan_xss |
Unescaped echo $_GET, Blade {!! !!}, Twig ` |
π Framework Integration (7)
| Tool | Purpose |
|---|---|
detect_framework |
Laravel / Symfony / WordPress / β¦ otomatik tespit. |
laravel_artisan |
php artisan <command> Γ§alΔ±ΕtΔ±r. β οΈ |
laravel_routes |
TΓΌm route'lar (method, uri, name, action, middleware). |
laravel_migrations |
php artisan migrate:status. |
symfony_console |
bin/console <command>. β οΈ |
symfony_container |
debug:container ile servis listesi. |
π Meta-tools (2)
| Tool | Purpose |
|---|---|
phpustik_doctor |
Tek Γ§aΔrΔ±da tΓΌm kalite/gΓΌvenlik/test kontrollerini Γ§alΔ±ΕtΔ±rΔ±r, priorize rapor dΓΆner. |
phpustik_init |
PHPStan / Psalm / Rector / phpcs / phpunit / .editorconfig / .gitattributes / CI workflow ΓΌretir. |
π Resources (8)
Resources are server-side data the model can read on demand to enrich its context. No parameters required.
| URI | MIME | Description |
|---|---|---|
phpustik://workspace |
text/plain |
Aktif proje ΓΆzeti (root, config dosyalarΔ±). |
phpustik://composer-json |
application/json |
composer.json iΓ§eriΔi. |
phpustik://composer-extra |
application/json |
composer.json extra bloΔu. |
phpustik://php-version |
text/plain |
.php-version iΓ§eriΔi. |
phpustik://framework |
application/json |
Tespit edilen framework + sΓΌrΓΌm. |
php://info |
text/plain |
php -i Γ§Δ±ktΔ±sΔ± (ilk 200 satΔ±r). |
php://extensions |
text/plain |
php -m (yΓΌklΓΌ eklentiler). |
php://ini-loaded |
application/json |
Sistem + proje INI dosyalarΔ±. |
π¬ Prompts (7)
Prompts are pre-baked, parameterised workflows the model can invoke.
| Prompt | Arguments | Purpose |
|---|---|---|
review_php_code |
filepath, focus |
PSR-12, gΓΌvenlik ve performans review. |
explain_php_code |
filepath, depth |
SatΔ±r satΔ±r kod aΓ§Δ±klamasΔ±. |
refactor_php_code |
filepath, goal |
Somut refactoring ΓΆnerileri + deΔiΕiklik ΓΆrnekleri. |
write_phpunit_test |
filepath, method?, coverage |
PHPUnit testi ΓΌret. |
write_pest_test |
filepath, method? |
Pest testi ΓΌret. |
security_audit |
path? |
4'lΓΌ gΓΌvenlik taramasΔ± baΕlat. |
upgrade_php |
fromVersion, toVersion |
PHP sΓΌrΓΌm yΓΌkseltme yol haritasΔ±. |
π Integrations
The server speaks stdio MCP β any client that supports MCP can use it.
Cursor
Settings β MCP β + Add new global MCP server:
{
"mcpServers": {
"phpustik": {
"command": "npx",
"args": ["-y", "phpustik"]
}
}
}
Claude Desktop
Edit claude_desktop_config.json:
{
"mcpServers": {
"phpustik": {
"command": "npx",
"args": ["-y", "phpustik"]
}
}
}
Claude Code (CLI)
claude mcp add phpustik -- npx -y phpustik
claude mcp list
Opencode
~/.config/opencode/mcp.json:
{
"mcpServers": {
"phpustik": {
"command": "npx",
"args": ["-y", "phpustik"]
}
}
}
Cline / Continue.dev
.vscode/cline_mcp_settings.json:
{
"mcpServers": {
"phpustik": { "command": "npx", "args": ["-y", "phpustik"] }
}
}
βοΈ Configuration
All via env vars. Everything has a sensible default.
| Variable | Default | Description |
|---|---|---|
PHPUSTIK_LOG_LEVEL |
info |
debug / info / warn / error β stderr. |
PHPUSTIK_CACHE_TTL |
60000 |
Tool result cache TTL (ms). |
PHPUSTIK_TIMEOUT_MS |
30000 |
Default command timeout. |
PHPUSTIK_PHPSTAN_BIN |
phpstan |
Override PHPStan binary path. |
PHPUSTIK_PSALM_BIN |
psalm |
Override Psalm binary path. |
PHPUSTIK_PHPCS_BIN |
phpcs |
Override PHPCS binary path. |
PATH |
β | The system PATH is used to find every PHP tool. |
π§― Troubleshooting
Common issues & fixes:
<details> <summary><strong>Server starts but the model reports "tool not found".</strong></summary>
- Make sure the MCP client config is valid JSON. Trailing commas break it.
- Restart the MCP client after editing the config.
- Run the server manually:
npx -y phpustik. If it crashes, the issue is server-side.
</details>
<details> <summary><strong>"PHPStan / Psalm / PHPMD β¦ bulunamadΔ±" errors.</strong></summary>
composer global require phpstan/phpstan
Make sure ~/.composer/vendor/bin is on your PATH. Restart the terminal and the MCP client.
</details>
<details> <summary><strong>Windows: "php is not recognized".</strong></summary>
Add C:\php to Path in System Environment Variables, then restart the terminal and the MCP client.
</details>
<details> <summary><strong>The server exits silently with no log line.</strong></summary>
The server sends logs to stderr and protocol frames to stdout. If your client shows nothing, set PHPUSTIK_LOG_LEVEL=debug and check its log panel.
</details>
<details>
<summary><strong>@cfworker/json-schema missing.</strong></summary>
npm install @cfworker/json-schema
It's a peer dep of the MCP SDK v2 alpha.
</details>
π Security
- No
shell: true. Every command runs throughexecFileβ arguments are never parsed as shell. - Every tool input goes through Zod validation before any IO.
- File-system access is read-only by default. Destructive tools are clearly marked β οΈ.
- Output buffers are capped at 1 MiB per stream.
- File contents are never logged β only paths and metadata.
Please report security issues privately β see SECURITY.md.
πΊ Roadmap
- [ ]
php -Smanaged dev server tool - [ ]
phpdbginteractive debugging - [ ]
php -dini override preview - [ ] Docker image:
phpustik/phpustik:latestwith every tool pre-installed - [ ] HTTP/SSE transport for remote deployments
- [ ] VS Code extension proxy
- [ ] GitHub Actions annotation output for CI integration
π€ Contributing
See CONTRIBUTING.md. Run npm run lint && npm run typecheck && npm run build before opening a PR.
π License
MIT β Β© 2024-2026 phpustik contributors.
π Acknowledgements
- The Model Context Protocol team for the spec and SDK.
- PHPStan, Psalm, PHPMD, PHPCS, Rector, PHP Insights and PHP-CS-Fixer β every PHP tool that makes this server possible.
- Composer for dependency management.
- Everyone who βοΈs, opens issues or sends PRs.
<div align="center">
Made with β€οΈ for the PHP + AI community.
</div>
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.