npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@webkult/phpstan-mcp-server

v1.0.0

Published

MCP server for PHPStan analysis - enables Claude to run static analysis directly

Downloads

16

Readme

PHPStan MCP Server

🤖 Model Context Protocol server for PHPStan - enables Claude to run static analysis directly.

Uses phpstan-ai-formatter for AI-optimized, token-efficient output.

What is this?

This MCP server allows Claude (via Claude Desktop or API) to:

  • Run PHPStan analysis on your PHP code
  • Get AI-optimized error reports (80% fewer tokens)
  • Iterate on fixes automatically
  • Verify code quality without leaving the conversation

Prerequisites

  • Node.js 18 or higher
  • A PHP project with Composer
  • PHPStan and phpstan-ai-formatter installed in your project

Installation

Global Installation (Recommended)

npm install -g @webkult/phpstan-mcp-server

Project-Local Installation

npm install @webkult/phpstan-mcp-server

Setup with Claude Desktop

  1. Install the server globally (see above)

  2. Edit your Claude Desktop configuration:

macOS/Linux:

code ~/.config/claude/config.json

Windows:

code %APPDATA%\Claude\config.json
  1. Add the server to your config:
{
  "mcpServers": {
    "phpstan": {
      "command": "phpstan-mcp-server"
    }
  }
}
  1. Restart Claude Desktop

Setup Your PHP Project

In your PHP project, install PHPStan with the AI formatter:

composer require --dev phpstan/phpstan hackbard/phpstan-ai-formatter

Create a phpstan.neon config (optional):

parameters:
    level: max
    paths:
        - src

Usage in Claude

Once configured, you can ask Claude to analyze your code:

You: "Analyze src/UserService.php with PHPStan"

Claude: [uses phpstan tool automatically]
"I found 3 issues in UserService.php:

1. Line 23: Method param $user: User|null ≠ User
   Fix: Add null check or update type hint

2. Line 45: getUser() → User|null (expected User)
   Fix: Update return type or handle null case

3. Line 67: Undefined property: $email
   Fix: Add property declaration

Would you like me to generate the fixes?"

Interactive Workflow

You: "Fix these issues and verify"

Claude: [generates fixes]
       [runs PHPStan again to verify]
       "✅ All issues resolved! Code now passes PHPStan level max."

Available Tools

The server provides these tools to Claude:

analyze_php

Run PHPStan analysis on files or directories.

Parameters:

  • path (required): File or directory to analyze
  • level (optional): Analysis level 0-9 or "max" (default: "max")
  • format (optional): Output format "ai" or "ai-json" (default: "ai-json")

Example:

{
  "path": "src/UserService.php",
  "level": "max",
  "format": "ai-json"
}

check_phpstan

Check if PHPStan is installed and configured.

No parameters required.

Output Formats

ai-json (Default)

Structured JSON output optimized for AI parsing:

{
  "totals": {
    "errors": 2,
    "warnings": 0
  },
  "files": {
    "src/UserService.php": [
      {
        "line": 23,
        "message": "Method param $user: User|null ≠ User",
        "ignorable": true
      }
    ]
  }
}

ai (Text)

Human-readable compact text format:

PHPStan Analysis
Found: 2 errors, 0 warnings

Errors
------
src/UserService.php:23 | Method param $user: User|null ≠ User
src/UserService.php:45 | getUser() → User|null (expected User)

Troubleshooting

"PHPStan not found"

Install PHPStan in your project:

composer require --dev phpstan/phpstan hackbard/phpstan-ai-formatter

"No composer.json found"

Make sure you're running this in a PHP project with Composer. Navigate to your project root:

cd /path/to/your/php/project

"Path not found"

Use paths relative to your project root:

✅ analyze_php("src/Services/UserService.php")
❌ analyze_php("/absolute/path/to/file.php")

Server not appearing in Claude Desktop

  1. Check config file location is correct
  2. Ensure JSON is valid (use a validator)
  3. Restart Claude Desktop completely
  4. Check Claude Desktop logs for errors

Development

Local Testing

# Clone the repo
git clone https://github.com/webkult/phpstan-mcp-server.git
cd phpstan-mcp-server

# Install dependencies
npm install

# Run locally
node index.js

Testing with Claude Desktop

Point to your local version in config:

{
  "mcpServers": {
    "phpstan": {
      "command": "node",
      "args": ["/path/to/phpstan-mcp-server/index.js"]
    }
  }
}

Related Projects

License

MIT License - see LICENSE file for details.

Support


Made with 🤖 for Claude Desktop users

Part of the PHPStan AI ecosystem