Get the FREE Ultimate OpenClaw Setup Guide →

spx

An MCP server for the SPX PHP Profiler

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio minicodemonkey-spx-mcp-server php artisan spx-mcp:start \
  --env SPX_DATA_DIR="path/to/spx/data" \
  --env SPX_MCP_ENABLED="true"

How to use

This MCP server bridges the PHP SPX profiler with Claude Code, enabling AI-assisted analysis of Laravel applications. After you install and enable the SPX MCP server, SPX profiles generated by the PHP SPX extension are parsed and exposed as MCP tools that Claude Code can invoke. You can ask Claude questions like which functions are slow, where memory usage is high, or whether there are N+1 query patterns, and Claude will use the SPX-derived metrics to provide actionable insights. Available tools include listing profiles, identifying slow functions, memory hogs, CPU-intensive operations, and generating call trees or timelines for deeper investigation. Use Claude Code to query the most impactful parts of your request flow, middleware chains, and database interactions, with results presented as structured analysis and recommended optimizations.

How to install

Prerequisites: - PHP installed (matching your Laravel project requirements, e.g., PHP 8.1+). - Composer installed. - A Laravel project set up where you want SPX profiling. - The PHP SPX extension installed and configured, including spx.data_dir set in php.ini. 1) In your Laravel project, install the MCP server package: php composer.phar require codemonkey/spx-mcp-server --dev 2) Publish or configure the MCP integration. You can use Claude Code’s built-in installer (php artisan spx-mcp:install) to automatically add the server to Claude Code, or manually add the server entry in Claude Code’s config (e.g., ~/.config/claude-code/config.json) with the server command and working directory. 3) Ensure environment alignment: SPX_MCP_ENABLED=true and SPX_DATA_DIR matches your PHP SPX configuration. 4) Start the MCP server: php artisan spx-mcp:start. 5) In Claude Code, configure Claude to connect to the spx-mcp endpoint if needed and verify that profiles are detectable by Claude’s MCP tooling.

Additional notes

Tips and common issues: - Ensure the spx.data_dir path in php.ini matches SPX_DATA_DIR environment variable used by the MCP server. Profiles are stored as .txt.gz in that directory. - The MCP server relies on the PHP SPX extension being loaded (check php -m | grep spx). - If the MCP server cannot connect, verify the cwd in the mcp_config points to your Laravel project and that php artisan spx-mcp:start runs without errors. - You can customize behavior via environment variables; SPX_MCP_ENABLED toggles the server, while SPX_DATA_DIR should reflect your SPX data storage location. - When generating profiles, trigger SPX during requests (e.g., SPX_KEY and SPX_UI_URI controls) and ensure SPX profiles are being created in the configured data directory. - If Claude Code cannot locate profiles, confirm the SPX data directory path matches the php.ini configuration and that profiles have the correct .txt.gz extension.

Related MCP Servers

Sponsor this space

Reach thousands of developers