The Pprof Analyzer MCP server is a specialized Go tool that helps analyze performance profiles generated by Go's pprof profiler. It enables detailed examination of CPU, memory, and goroutine performance data through a Model Context Protocol (MCP) interface.
The simplest way to install the server:
go install github.com/ZephyrDeng/pprof-analyzer-mcp@latest
This will install the executable to your $GOPATH/bin
or $HOME/go/bin
directory. Ensure this directory is in your PATH to run the command directly.
If you prefer to build from source:
# Clone the repository (if needed)
git clone https://github.com/ZephyrDeng/pprof-analyzer-mcp.git
cd pprof-analyzer-mcp
# Build the executable
go build
Docker provides a convenient way to run the server with all dependencies included:
Build the Docker image:
docker build -t pprof-analyzer-mcp .
Run the container:
docker run -i --rm pprof-analyzer-mcp
Graphviz: Required for generating flame graph SVGs. Install it on your system:
macOS:
brew install graphviz
Debian/Ubuntu:
sudo apt-get update && sudo apt-get install graphviz
CentOS/Fedora:
sudo yum install graphviz
# or
sudo dnf install graphviz
Windows (using Chocolatey):
choco install graphviz
Configure your MCP client (like Roo Cline extension for VS Code) by adding this to your .roo/mcp.json
file:
{
"mcpServers": {
"pprof-analyzer": {
"command": "pprof-analyzer-mcp"
}
}
}
For Docker usage:
{
"mcpServers": {
"pprof-analyzer-docker": {
"command": "docker run -i --rm pprof-analyzer-mcp"
}
}
}
The analyze_pprof
tool examines performance profiles and returns analysis results:
{
"tool_name": "analyze_pprof",
"arguments": {
"profile_uri": "file:///path/to/your/cpu.pprof",
"profile_type": "cpu",
"output_format": "text",
"top_n": 5
}
}
Parameters:
profile_uri
: Path to the profile file (supports file://
, http://
, or https://
)profile_type
: One of cpu
, heap
, goroutine
, allocs
, mutex
, or block
output_format
: Optional - text
(default), markdown
, json
, or flamegraph-json
top_n
: Optional - number of top results to display (default: 5)The generate_flamegraph
tool creates SVG flame graphs:
{
"tool_name": "generate_flamegraph",
"arguments": {
"profile_uri": "file:///path/to/your/cpu.pprof",
"profile_type": "cpu",
"output_svg_path": "/path/to/save/cpu_flamegraph.svg"
}
}
Parameters:
profile_uri
: Path to the profile fileprofile_type
: Type of profile to analyzeoutput_svg_path
: Where to save the generated SVG fileLaunch the interactive web UI for pprof:
{
"tool_name": "open_interactive_pprof",
"arguments": {
"profile_uri": "file:///path/to/your/cpu.pprof",
"http_address": ":8082" // Optional, defaults to :8081
}
}
Compare two heap profiles to identify potential memory leaks:
{
"tool_name": "detect_memory_leaks",
"arguments": {
"old_profile_uri": "file:///path/to/heap_before.pprof",
"new_profile_uri": "file:///path/to/heap_after.pprof",
"threshold": 0.05, // 5% growth threshold
"limit": 15 // Show top 15 potential leaks
}
}
Terminate a previously opened pprof interactive session:
{
"tool_name": "disconnect_pprof_session",
"arguments": {
"pid": 12345 // The PID returned by open_interactive_pprof
}
}
Analyzing CPU bottlenecks:
{
"tool_name": "analyze_pprof",
"arguments": {
"profile_uri": "https://raw.githubusercontent.com/google/pprof/refs/heads/main/profile/testdata/gobench.cpu",
"profile_type": "cpu",
"output_format": "flamegraph-json"
}
}
Examining memory usage with detailed output:
{
"tool_name": "analyze_pprof",
"arguments": {
"profile_uri": "file:///path/to/your/heap.pprof",
"profile_type": "heap",
"output_format": "markdown",
"top_n": 10
}
}
Inspecting goroutine patterns:
{
"tool_name": "analyze_pprof",
"arguments": {
"profile_uri": "file:///path/to/your/goroutine.pprof",
"profile_type": "goroutine"
}
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "pprof-analyzer" '{"command":"pprof-analyzer-mcp"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"pprof-analyzer": {
"command": "pprof-analyzer-mcp"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"pprof-analyzer": {
"command": "pprof-analyzer-mcp"
}
}
}
3. Restart Claude Desktop for the changes to take effect