Skip to main content
Glama
PHP Legacy Auditor

PHP Legacy Auditor

PHP Legacy Auditor (MCP server)

CI Python 3.10+ License: MIT

A read-only Model Context Protocol server that audits legacy PHP projects with four static analysis tools:

Tool

Purpose

run_semgrep_scan

SAST rules for legacy PHP (rules/legacy_php.yaml)

run_psalm_scan

Type/security analysis (Psalm)

run_progpilot_scan

Taint analysis for PHP (Progpilot)

run_phpcs_scan

Code style / PHP coding standards (PHPCS)

Other tools: get_auditor_status, map_project_structure, read_code_context.

Requirements

  • Python 3.10+

  • PHP 8.1+ (needed by Psalm, Progpilot and PHPCS)

  • The official mcp SDK (FastMCP) — install with pip install -e .

  • pydantic (already a dependency of mcp)

Tool-specific dependencies

Install the dev dependencies with Composer (they ship the PHP binaries):

composer install --no-interaction --no-progress

Binary

How it is provided

semgrep

Python package, pip install semgrep

psalm

vendor/bin/psalm (Composer)

progpilot

vendor/bin/progpilot (Composer)

phpcs

vendor/bin/phpcs (Composer)

Related MCP server: Ecosystem Intelligence MCP

Configuration

Allow-listed audit root

The server only ever scans directories inside ALLOWED_AUDIT_ROOT. Set it before starting the server:

export ALLOWED_AUDIT_ROOT=/path/to/legacy-app
python -m php_legacy_auditor.server

If ALLOWED_AUDIT_ROOT is not set, the tools still run (the server logs a warning) but the root validation is disabled.

Server launch

# With the package installed
mcp serve php_legacy_auditor.server

# Or directly with the SDK
python -m mcp.server.fastmcp php_legacy_auditor.server

The FastMCP app is also importable: from php_legacy_auditor.server import mcp.

Tools reference

Tool

Arguments

Output

get_auditor_status

—

allowed_audit_root, resolved_allowed_audit_root, binaries

map_project_structure

target_dir

root, source_files, probable_php_version, entry_points

read_code_context

file_path, start_line, end_line

file, lines, truncated, max_lines_per_call

run_semgrep_scan

target, config

success, findings, semgrep_version, errors

run_psalm_scan

target, config

success, findings, psalm

run_progpilot_scan

target, config

success, status, findings, bin, raw_output_lines

run_phpcs_scan

target, standard

success, status, findings, bin, standard, raw_output_lines

Every tool is read-only: they never modify, delete, or execute the audited code. Paths are resolved and blocked when they escape ALLOWED_AUDIT_ROOT (validate_safe_path / security.py). Subprocesses are always invoked with an argument list and a strict timeout (no shell=True).

Output format

Scan tools return a compact JSON event per finding:

{
  "file": "/tmp/app.php",
  "line": 17,
  "severity": "WARNING",
  "rule": "legacy-php-mysql-connect",
  "message": "mysql_connect() is deprecated; use mysqli or PDO",
  "snippet": "<?php mysql_connect(...);"
}

Testing

# Unit tests (Python level)
python -m pytest tests/ -q

# All four tools on the sample vulnerable app
./scripts/run_all_audits.sh

The sample app lives in tests/sample_vulnerable_app/ and contains classic legacy PHP vulnerabilties (SQL injection, remote inclusion, eval(), unserialize()).

License

MIT (see LICENSE).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables security scanning of code projects to identify common vulnerabilities like XSS, injections, SSRF, and path traversal issues. Provides local, offline scanning with severity-grouped results and actionable fix suggestions for improving code security.
      38 npm
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables read-only auditing of repositories by scanning actual files, flagging risky code, secrets, and untrusted platform configs, and generating Chinese-language reports for human decision-making.
      18
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP clients to run deterministic, read-only local repository audits for risky GitHub workflows, undocumented environment variables, possible credentials, and conflicting dependency configuration, returning structured findings without sending source code to a service.
      58 npm
      MIT