Go pprof Analyzer MCP server

Analyzes Go performance profiles to extract key metrics and generate flame graphs for diagnosing bottlenecks, memory issues, and concurrency problems in Go applications.
Back to servers
Setup instructions
Provider
Zephyr Deng
Release date
Apr 14, 2025
Language
Go
Stats
20 stars

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.

Installation Options

Using Go Install

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.

Building from Source

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

Using Docker

Docker provides a convenient way to run the server with all dependencies included:

  1. Build the Docker image:

    docker build -t pprof-analyzer-mcp .
    
  2. Run the container:

    docker run -i --rm pprof-analyzer-mcp
    

Dependencies

  • 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
    

Setting Up Your MCP Client

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"
    }
  }
}

Using the Available Tools

Analyze Pprof Data

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)

Generate Flame Graphs

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 file
  • profile_type: Type of profile to analyze
  • output_svg_path: Where to save the generated SVG file

Open Interactive Pprof UI (macOS Only)

Launch 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
  }
}

Detect Memory Leaks

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
  }
}

Disconnect Pprof Session

Terminate a previously opened pprof interactive session:

{
  "tool_name": "disconnect_pprof_session",
  "arguments": {
    "pid": 12345  // The PID returned by open_interactive_pprof
  }
}

Example Usage Scenarios

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"
  }
}

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later