# phpgraph [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/hbenabdallah/phpgraph  
**GitHub Stars:** 2  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/phpgraph

## Description
Knowledge graph of a PHP codebase by static analysis: calls, routes, buses, layers, impact

## Tools
Capabilities this server exposes over MCP:

- **overview** — Start here: Composer stack, namespace tree with layers, bounded contexts, layer-rule violations, messages, HTTP routes (each with method, path, controller and file up to 30, else grouped by path prefix), services, and what the graph cannot see.
- **query_graph** — Find the code about a topic when you do not know the class names, by the words of their names (validated finds `Validator`), with the classes of the feature around the ones it names. A question about routes (*"mooc courses routes"*, *"GET /courses"*) returns the matching routes and their controller…
- **outline** — Before explaining a feature: its structural outline, enough to read only the few files with non-obvious logic. The classes it is made of, by namespace and layer, with the first sentence of their docblock, their public signatures, constants and enum cases; the interfaces and base classes around it w…
- **get_node** — Read one class, method, route or channel with all its relations; tests using it are counted by module.
- **get_neighbors** — See what uses a node (`in`) or what it depends on (`out`).
- **impact_of** — Before a change: every class that depends on a class or method, nearest first, with the lines of the calls; callers through the interface it implements; code depending on the state it writes; the routes reaching it, with each chain; and the tests to run, found through test helpers. It flags the cla…
- **shortest_path** — See how two pieces of code are connected.
- **god_nodes** — Find the hubs most of the code depends on.

## Claude Desktop Quick Installation
Heuristic fallback — verify the package name and runner against the repository README before running it. Uses `npx` (confidence: low):

```json
"mcpServers": {
  "phpgraph": {
    "command": "npx",
    "args": ["-y","phpgraph"]
  }
}
```

## Documentation

## What phpgraph MCP server does

The phpgraph MCP server parses a PHP project and represents its structural relationships as a graph. It can describe the Composer stack, namespace hierarchy, architectural layers, bounded contexts, layer-rule violations, services, messages, HTTP routes, and known blind spots. The analysis is deterministic: relationships are marked as extracted from code, inferred from declared types, or ambiguous when resolution is uncertain.

The graph covers common PHP patterns and frameworks, including Symfony, Laravel, Ecotone, PrestaShop, WordPress, and plain PHP. It can connect calls, message senders and handlers, routes and controllers, dependency-injection configuration, API schemas, protobuf implementations, and links between microservices. The project remains local; phpgraph parses code but does not run it.

## How it works

phpgraph uses nikic/php-parser to analyze the project. Its call analysis uses signatures, return types, local variables, docblocks, and dependency signatures to resolve direct and chained calls. It also reads relevant PHP, YAML, and XML configuration for services, routes, tags, and message wiring.

The phpgraph MCP server creates its graph when an agent first requests information, then rebuilds incrementally when files change. The README reports roughly three seconds per edit for an 8,400-file project. Unresolved calls, missing vendor files, messages without handlers, and other gaps are reported so an agent can distinguish known relationships from areas requiring source inspection.

## Setup and configuration

Installation is available as a standalone executable for Linux, macOS, and Windows, with architecture support described by the project. The install scripts verify the downloaded binary with SHA-256 and place it in a user directory; `PHPGRAPH_INSTALL_DIR` can change that location. Alternatives include Composer, a downloaded PHAR, or the published Docker image. Composer and Docker usage require the corresponding local tooling.

Run `phpgraph mcp-config` with a supported output target to generate connection configuration. The README documents formats for Sherpa, Claude Code, Codex, Cursor, and generic MCP clients over stdio. A direct server command uses `phpgraph serve` and can include the project path.

## Tools and capabilities

The phpgraph MCP server provides these tools:

- `overview` summarizes the project stack, namespaces, layers, contexts, violations, messages, routes, services, and analysis limits.
- `query_graph` searches by words in names and can return related classes or matching routes.
- `outline` presents a feature’s classes, layers, docblock opening sentences, public signatures, constants, enum cases, interfaces, and base classes.
- `get_node` reads a class, method, route, or channel with its relationships and module-level test counts.
- `get_neighbors` lists incoming users or outgoing dependencies.
- `impact_of` traces dependent classes and methods, interface callers, affected state consumers, route chains, relevant contracts, and tests.
- `shortest_path` finds a connection between two code elements.
- `god_nodes` identifies highly connected dependency hubs.

## Limitations and notes

Results depend on what static analysis can resolve. Dynamic or unresolved behavior may be absent or labelled as ambiguous, and the tool explicitly reports gaps rather than filling them with generated guesses. It is therefore suited to structural exploration and impact analysis, but agents may still need to read source files for logic the graph cannot establish.

The project requires PHP 8.2 or newer when using the PHP-based installation paths, while the standalone binary is supplied with a static PHP runtime. Its license is PolyForm Shield 1.0.0.

_Full upstream README: https://allmcps.com/mcp/phpgraph/readme_

