Sponsored by Deepsite.site

Perfetto

Created By
antarikshc3 months ago
A Model Context Protocol (MCP) server that transforms natural-language prompts into focused Perfetto analyses. Quickly explain jank, diagnose ANRs, spot CPU hot threads, uncover lock contention, and find memory leaks – all without writing SQL.
Content

Perfetto MCP

Turn natural language into powerful Perfetto trace analysis

A Model Context Protocol (MCP) server that transforms natural-language prompts into focused Perfetto analyses. Quickly explain jank, diagnose ANRs, spot CPU hot threads, uncover lock contention, and find memory leaks – all without writing SQL.

✨ Features

  • Natural Language → SQL: Ask questions in plain English, get precise Perfetto queries
  • ANR Detection: Automatically identify and analyze Application Not Responding events
  • Performance Analysis: CPU profiling, frame jank detection, memory leak detection
  • Thread Contention: Find synchronization bottlenecks and lock contention
  • Binder Profiling: Analyze IPC performance and slow system interactions

📋 Prerequisites

  • Python 3.13+ (macOS/Homebrew):
    brew install python@3.13
    
  • uv (recommended):
    brew install uv
    

🚀 Getting Started

Cursor

Install MCP Server

Or add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):

{
  "mcpServers": {
    "perfetto-mcp": {
      "command": "uvx",
      "args": ["perfetto-mcp"]
    }
  }
}
Claude Code

Run this command. See Claude Code MCP docs for more info.

# Add to user scope
claude mcp add perfetto-mcp --scope user -- uvx perfetto-mcp

Or edit ~/claude.json (macOS) or %APPDATA%\Claude\claude.json (Windows):

{
  "mcpServers": {
    "perfetto-mcp": {
      "command": "uvx",
      "args": ["perfetto-mcp"]
    }
  }
}
VS Code

Install in VS Code

or add to .vscode/mcp.json (project) or run "MCP: Add Server" command:

{
  "mcpServers": {
    "perfetto-mcp": {
      "command": "uvx",
      "args": ["perfetto-mcp"]
    }
  }
}

Enable in GitHub Copilot Chat's Agent mode.

Codex

Edit ~/.codex/config.toml:

[mcp_servers.perfetto-mcp]
command = "uvx"
args = ["perfetto-mcp"]

Local Install (development server)

cd perfetto-mcp-server
uv sync
uv run mcp dev src/perfetto_mcp/dev.py
Local MCP
{
  "mcpServers": {
    "perfetto-mcp-local": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/git/repo/perfetto-mcp",
        "run",
        "-m",
        "perfetto_mcp"
      ],
      "env": { "PYTHONPATH": "src" }
    }
  }
}
Using pip
pip3 install perfetto-mcp
python3 -m perfetto_mcp

📖 How to Use

Example starting prompt:

In the perfetto trace, I see that the FragmentManager is taking 438ms to execute. Can you figure out why it's taking so long?

Required Parameters

Every tool needs these two inputs:

ParameterDescriptionExample
trace_pathAbsolute path to your Perfetto trace/path/to/trace.perfetto-trace
process_nameTarget process/app namecom.example.app

In Your Prompts

Be explicit about the trace and process, prefix your prompt with:

"Use perfetto trace /absolute/path/to/trace.perfetto-trace for process com.example.app"

Optional Filters

Many tools support additional filtering (but let your LLM handle that):

  • time_range: {start_ms: 10000, end_ms: 25000}
  • Tool-specific thresholds: min_block_ms, jank_threshold_ms, limit

🛠️ Available Tools

🔎 Exploration & Discovery

ToolPurposeExample Prompt
find_slicesSurvey slice names and locate hot paths"Find slice names containing 'Choreographer' and show top examples"
execute_sql_queryRun custom PerfettoSQL for advanced analysis"Run custom SQL to correlate threads and frames in the first 30s"

🚨 ANR Analysis

Note: Helpful if the recorded trace contains ANR

ToolPurposeExample Prompt
detect_anrsFind ANR events with severity classification"Detect ANRs in the first 10s and summarize severity"
anr_root_cause_analyzerDeep-dive ANR causes with ranked likelihood"Analyze ANR root cause around 20,000 ms and rank likely causes"

🎯 Performance Profiling

ToolPurposeExample Prompt
cpu_utilization_profilerThread-level CPU usage and scheduling"Profile CPU usage by thread and flag the hottest threads"
main_thread_hotspot_slicesFind longest-running main thread operations"List main-thread hotspots >50 ms during 10s–25s"

📱 UI Performance

ToolPurposeExample Prompt
detect_jank_framesIdentify frames missing deadlines"Find janky frames above 16.67 ms and list the worst 20"
frame_performance_summaryOverall frame health metrics"Summarize frame performance and report jank rate and P99 CPU time"

🔒 Concurrency & IPC

ToolPurposeExample Prompt
thread_contention_analyzerFind synchronization bottlenecks"Find lock contention between 15s–30s and show worst waits"
binder_transaction_profilerAnalyze Binder IPC performance"Profile slow Binder transactions and group by server process"

💾 Memory Analysis

ToolPurposeExample Prompt
memory_leak_detectorFind sustained memory growth patterns"Detect memory-leak signals over the last 60s"
heap_dominator_tree_analyzerIdentify memory-hogging classes"Analyze heap dominator classes and list top offenders"

Output Format

All tools return structured JSON with:

  • Summary: High-level findings
  • Details: Tool-specific results
  • Metadata: Execution context and any fallbacks used

📄 License

Apache 2.0 License. See LICENSE for details.


GitHubIssuesDocumentation

Server Config

{
  "mcpServers": {
    "perfetto-mcp": {
      "command": "uvx",
      "args": [
        "perfetto-mcp"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Amap Maps高德地图官方 MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Tavily Mcp
CursorThe AI Code Editor
WindsurfThe new purpose-built IDE to harness magic
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Serper MCP ServerA Serper MCP Server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
Playwright McpPlaywright MCP server