@perfbase/mcp
v1.0.1
Published
MCP server for PerfBase profiler analysis
Maintainers
Readme
@perfbase/mcp
Model Context Protocol (MCP) server for analyzing PerfBase PHP profiler data.
Installation
claude mcp add perfbase -- npx -y @perfbase/mcpThat's it! Restart Claude Code and you can profile and analyze PHP scripts directly.
Usage
Profile a PHP Script
Just ask Claude to profile any PHP script:
Profile /path/to/my-script.php and show me the slowest functionsClaude will use the run_profiled_script tool to execute the script with profiling enabled, then analyze the results.
Analyze an Existing Profile
Analyze the profile at /path/to/profile.binAvailable Tools
| Tool | Description |
|------|-------------|
| run_profiled_script | Run a PHP script with profiling and save the result |
| get_slowest_functions | Functions sorted by total wall time |
| get_most_called_functions | Functions sorted by call count |
| get_cpu_intensive_functions | Functions sorted by CPU time |
| get_memory_hogs | Functions sorted by memory allocation |
| get_database_queries | Extract and analyze database operations |
| detect_n_plus_one | Find N+1 query patterns |
| get_profile_summary | Overall profile statistics |
Profile Data Format
PerfBase profiles are:
- MessagePack encoded
- Brotli compressed
This is the raw binary format produced by perfbase_get_data().
Development
# Clone and install
git clone <repo>
cd mcp
npm install
# Build
npm run build
# Watch mode
npm run dev
# Run tests
npm testLocal Testing
To test locally before publishing:
claude mcp add perfbase -- node /path/to/extension/mcp/dist/index.jsManual Profile Generation
<?php
perfbase_enable('test', PERFBASE_FLAG_ALL);
// ... your code ...
perfbase_disable('test');
file_put_contents('profile.bin', perfbase_get_data());License
MIT
