Download the PHP package codemonkey/spx-mcp-server without Composer
On this page you can find all versions of the php package codemonkey/spx-mcp-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codemonkey/spx-mcp-server
More information about codemonkey/spx-mcp-server
Files in codemonkey/spx-mcp-server
Package spx-mcp-server
Short Description An MCP server for the PHP SPX profiler
License MIT
Informations about the package spx-mcp-server
Experimental PHP SPX MCP Server 🚀
An MCP (Model Context Protocol) server for Laravel applications that brings the power of PHP SPX profiler to Claude Code. Analyze PHP application performance with AI assistance, getting intelligent insights into bottlenecks, memory usage, database queries, and more.
🎯 What is This?
The PHP SPX MCP Server is a bridge between the powerful PHP SPX profiler and Claude Code (or any MCP-compatible AI client). It enables you to:
- 🔍 Analyze performance profiles with natural language queries
- 📊 Get AI-powered insights into bottlenecks and optimization opportunities
- 🎯 Identify N+1 queries, memory leaks, and slow functions automatically
- 📈 Visualize call trees, execution timelines, and middleware chains
- 💡 Receive actionable recommendations for performance improvements
Instead of manually digging through profiler data, simply ask Claude: "What's causing the slowest response times?" or "Are there any N+1 query issues?"
🛠️ Prerequisites
PHP SPX Extension
You must have the PHP SPX extension installed and configured. Please refer to the official installation instructions at:
https://github.com/NoiseByNorthwest/php-spx
Important: Make sure to configure the spx.data_dir setting in your php.ini. This is where SPX will store profile data, and the MCP server needs to read from this location.
Example configuration:
📦 Installation
Install the SPX MCP Server via Composer in your Laravel project:
⚙️ Configuration
Configure with Claude Code
The easiest way to configure the MCP server with Claude Code is using the built-in installation command:
This will automatically add the SPX MCP server to your Claude Code configuration.
Manual Configuration
Alternatively, you can manually add the server to your Claude Code configuration file (~/.config/claude-code/config.json):
Environment Variables
You can customize the SPX MCP server behavior using environment variables in your .env file:
You can also publish the configuration file for more control:
🎮 Usage
1. Generate SPX Profiles
Generate performance profiles by triggering SPX during your application requests. Add the SPX trigger to your request URL:
Or use the SPX web UI to control profiling: http://your-app.test/?SPX_KEY=dev&SPX_UI_URI=/
Profiles will be saved to your configured spx.data_dir.
2. Analyze with Claude Code
Once you have generated profiles, open Claude Code and start asking questions:
Example queries:
- "List all available SPX profiles"
- "Analyze the latest profile and show me the slowest functions"
- "Are there any N+1 database query issues?"
- "What middleware is taking the most time?"
- "Show me the call tree for the most recent profile"
- "Which third-party packages are impacting performance?"
- "Find any recursive functions and their overhead"
- "What's the wall time vs CPU time distribution?"
Claude will use the MCP tools to parse your SPX profiles and provide intelligent analysis and recommendations.
🧰 Available MCP Tools
The SPX MCP server provides the following analysis tools:
| Tool | Description |
|---|---|
list_profiles |
List all available SPX profiles |
get_slowest_functions |
Get functions with highest exclusive execution time |
get_most_called_functions |
Get most frequently called functions |
get_memory_hogs |
Get functions using the most memory |
get_cpu_intensive_functions |
Get CPU-intensive functions |
get_call_tree |
Get hierarchical call tree structure |
get_timeline_view |
Get chronological execution timeline |
get_recursive_functions |
Identify recursive function calls |
get_wall_time_distribution |
Analyze I/O vs CPU time distribution |
get_autoloading_overhead |
Analyze autoloading performance impact |
get_third_party_package_impact |
Analyze third-party package performance |
get_database_queries |
Analyze database operations and detect N+1 queries |
get_redis_operations |
Analyze Redis/cache operations |
get_io_operations |
Analyze file, network, and socket I/O |
get_middleware_analysis |
Analyze middleware execution order and timing |
📊 Example Analysis
🏗️ How It Works
- Profile Generation: PHP SPX profiles your application and stores detailed execution traces
- Profile Parsing: The MCP server reads and parses SPX profile files (compressed
.txt.gzformat) - Data Analysis: Profiles are analyzed to extract metrics like execution time, memory, call counts, etc.
- MCP Tools: Analysis results are exposed as MCP tools that Claude can invoke
- AI Insights: Claude uses the tools to answer your questions and provide recommendations
🔧 Development
Running Tests
Project Structure
🐛 Troubleshooting
SPX profiles not being created?
- Verify SPX is installed:
php -m | grep spx - Check your
php.iniconfiguration - Ensure
spx.data_diris configured and writable - Refer to PHP SPX documentation
MCP server not connecting?
- Verify the path in your Claude Code config is correct
- Check that the server starts:
php artisan spx-mcp:start - Review logs in
storage/logs/laravel.log
No profiles showing in Claude?
- Verify profiles exist in your SPX data directory
- Check the
SPX_DATA_DIRenvironment variable matches yourphp.inisetting - Ensure profiles have
.txt.gzextension
📝 License
This package is open-sourced software licensed under the MIT license.
🙏 Credits
- Built on PHP SPX by NoiseByNorthwest
- Uses Laravel's MCP package
- Created by Mathias Hansen
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Made with ❤️ by developers who hate performance issues