perf-mcp

perf-mcp

Enables LLMs to analyze Linux perf data files using 26 perf analysis commands, including report, script, annotate, and more, through typed tool parameters.

Category
Visit Server

README

perf-mcp

MCP server for Linux perf. Gives LLMs structured access to perf report, perf script, perf annotate, and 23 other perf analysis commands through typed tool parameters.

Operates on existing perf.data files only -- no recording, no system modification.

Requirements

  • Linux with perf installed (perf --version)
  • Python 3.12+
  • uv

Quick Start

git clone <repo-url> ~/work/perf-mcp
cd ~/work/perf-mcp
uv sync

Claude Code

Add to .mcp.json (project or global):

{
  "mcpServers": {
    "perf-mcp": {
      "command": "uv",
      "args": ["run", "--directory", "<path-to-perf-mcp>", "perf-mcp"]
    }
  }
}

Replace <path-to-perf-mcp> with the absolute path to your clone.

Other MCP Clients

Run as a stdio MCP server:

cd ~/work/perf-mcp
uv run perf-mcp

Configuration

Environment Variable Default Description
PERF_BINARY perf Path to the perf binary
PERF_TIMEOUT 60 Command timeout in seconds (max 300)
PERF_MAX_OUTPUT_BYTES 2000000 Output truncation limit (bytes)

Set via the env key in .mcp.json:

{
  "mcpServers": {
    "perf-mcp": {
      "command": "uv",
      "args": ["run", "--directory", "<path>", "perf-mcp"],
      "env": {
        "PERF_TIMEOUT": "120"
      }
    }
  }
}

Tools

26 tools across 7 categories. Each wraps a perf subcommand with every CLI option exposed as a typed parameter.

Core Analysis

Tool Command What it does
perf_evlist perf evlist List recorded events (start here)
perf_report perf report Overhead histogram by symbol/DSO/thread
perf_script perf script Raw per-sample event dump
perf_annotate perf annotate Source/assembly with per-line hit counts
perf_diff perf diff Compare two profiles side-by-side
perf_c2c_report perf c2c report False sharing / cache contention
perf_inject perf inject Decode Intel PT, inject build IDs

Scheduler

Tool Command
perf_sched_latency Per-task scheduling latency stats
perf_sched_timehist Timestamped context switch timeline
perf_sched_map ASCII CPU activity map
perf_sched_script Raw scheduler event dump
perf_sched_replay Replay scheduling for simulation

Locks

Tool Command
perf_lock_report Lock acquire/contention statistics
perf_lock_contention Contention analysis with BPF support
perf_lock_info Lock type information

Kernel Work Items

Tool Command
perf_kwork_report IRQ/softirq/workqueue statistics
perf_kwork_latency Work item latency breakdown
perf_kwork_timehist Timestamped work item events
perf_kwork_top Top work items by runtime

Memory, KVM, Utilities

Tool Command
perf_kmem_stat Kernel memory allocation stats
perf_mem_report Memory access data source analysis
perf_kvm_stat_report KVM VM exit statistics
perf_timechart Generate scheduling timechart SVG
perf_buildid_list List binary build IDs
perf_data_convert Convert perf.data to JSON/CTF
perf_kallsyms Kernel symbol lookup

Typical Workflow

  1. Record a profile (outside this tool): perf record -g -a -- sleep 10
  2. Ask the LLM to analyze it:
    • "What events are in ./perf.data?" -- calls perf_evlist
    • "Show the top CPU consumers" -- calls perf_report
    • "Annotate the hottest function" -- calls perf_annotate
    • "Show the raw samples for malloc" -- calls perf_script with symbols='malloc'
    • "Compare before and after" -- calls perf_diff

Safety

  • Read-only -- no recording or data modification commands
  • Path validation -- input/output paths validated, /proc /sys /dev /etc blocked
  • No code execution -- --script, --dlfilter, --objdump, --addr2line options excluded
  • Timeout enforcement -- processes killed after the configured limit
  • Output truncation -- large outputs capped with a clear marker
  • No shell -- all commands use subprocess.exec (no shell injection)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured