Get the FREE Ultimate OpenClaw Setup Guide →

php-ast

MCP (Model Context Protocol) local server for PHP AST (Abstract Syntax Tree) analysis and visualization

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio nayte91-php-ast-mcp-server docker run -i nayte91/php-ast-mcp-server:latest

How to use

This MCP server exposes PHP AST analysis capabilities. It parses PHP source code into an Abstract Syntax Tree using the php-ast extension, analyzes code structure (classes, methods, functions, properties), and outputs JSON compatible with MCP clients. The server is designed to be run locally via Docker. You can feed it a PHP project directory and receive structured data about the codebase, with options to filter by visibility (public only or all) as described in the README. Use it to understand code organization, generate tooling data, or power code intelligence features in your MCP workflow.

How to install

Prerequisites:

  • Docker installed and running
  • Git (optional, for cloning the repository)

Installation steps:

  1. Pull or build the Docker image for the MCP server. If using the published image name from the README slug, you can pull directly: docker pull nayte91/php-ast-mcp-server:latest
  2. Run the server for local development. The server is configured to start serving PHP AST analysis via the container: docker run -p 8080:8080 -i nayte91/php-ast-mcp-server:latest
  3. If you prefer building from source, clone the repository and build the image according to the repository's Dockerfile instructions, then run as above.
  4. Verify the server is responsive by hitting the MCP endpoint from a client, for example via curl or your MCP tooling, and ensure you receive JSON output.

Notes:

  • Ensure the php-ast PHP extension is available inside the container (as per the repository's Containerfile).
  • The server serves locally; use localhost and the appropriate port configured by the container.

Additional notes

Tips and common issues:

  • If you see token usage mismatches, verify that you’re using the public-only or all-visibility options as described in the README when requesting AST output.
  • The Docker image name in use is nayte91/php-ast-mcp-server:latest; replace with a specific tag if needed.
  • Ensure your MCP client configurations point to the server’s endpoint and expect JSON in the same structure as MCP standard outputs.
  • For large PHP codebases, consider running the analysis on directories recursively and streaming results to the client to avoid heavy memory usage.

Related MCP Servers

Sponsor this space

Reach thousands of developers