Perfonext Profiler MCP

v0.7.3
io.github.souvikdu/perfonext-profiler-mcp Checked 1 day ago Published 2 months ago

MCP server for analyzing V8/Chrome CPU profiles with line-level tick attribution.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

load_profile Load CPU Profile

Parse and load a V8/Chrome CPU profile from disk. Supports both .cpuprofile files and Chrome DevTools Trace JSON exports. Returns a profile ID for use with other tools.

ParameterTypeDescription
filePath *stringAbsolute or relative path to the .cpuprofile or Chrome trace .json file

get_hotspots Get Hotspots

Returns the top N functions by self-time (CPU time spent directly in the function, not its callees). Use this to find performance bottlenecks.

ParameterTypeDescription
profileId *stringProfile ID returned by load_profile
limitnumberNumber of hotspots to return (default: 10)

explain_function Explain Function

Returns detailed timing info for a specific function: self-time, total-time, callers, and callees. Use this to understand why a function is slow.

ParameterTypeDescription
functionName *stringExact function name to look up
profileId *stringProfile ID returned by load_profile
contextLinesintegerOnly used with includeSource: minimum lines of padding around the declaration and hot lines (default: 10)
includeSourcebooleanWhen true, include annotated source code lines with per-line tick counts (default: false)

compare_profiles Compare Profiles

Compare two loaded CPU profiles side-by-side. Shows functions that got slower/faster and new/removed hotspots.

ParameterTypeDescription
baseProfileId *stringProfile ID of the baseline (before)
compareProfileId *stringProfile ID to compare (after)
limitnumberNumber of top changes to show

suggest_optimizations Suggest Optimizations

Analyzes the profile and returns structured optimization suggestions for the hottest functions. Detects high fan-in, recursion, dominant callers, V8-specific patterns, always reports CPU self-time cost for expensive functions, and deduplicates functions split across multiple call sites.

ParameterTypeDescription
profileId *stringProfile ID returned by load_profile
limitnumberNumber of functions to analyze (default: 5)

get_profile_summary Get Profile Summary

Returns an overview of a loaded profile: duration, sample count, top-level call tree (filtered to functions >0.1% of total time), and idle time percentage. For large profiles, the call tree is limited to depth 2 and top 20 children per node to keep output manageable. Also lists all loaded profiles if no ID is given.

ParameterTypeDescription
profileIdstringProfile ID. If omitted, lists all loaded profiles.
treeDepthnumberDepth of call tree to include (default: 2, max: 5)

read_source_context Read Source Context

Read the actual source code for a hot function and annotate each line with sampled tick counts from positionTicks. The returned window is sized to cover the function's actual hot lines, not just the area around its declaration; if any ticks still fall outside it, a `warning` field reports how many and suggests a larger contextLines. Only reads files within the project root.

ParameterTypeDescription
functionName *stringExact function name to look up
profileId *stringProfile ID returned by load_profile
contextLinesintegerMinimum lines of padding around the function declaration and its hot lines (default: 10)

get_package_costs Get Package Costs

Aggregate CPU self-time by npm package. Identifies which third-party dependencies are consuming the most CPU, by parsing node_modules paths from the profile. Useful for deciding which packages to replace, lazy-load, or avoid. Scoped packages (e.g. @babel/core) are handled correctly.

ParameterTypeDescription
profileId *stringProfile ID returned by load_profile
limitintegerMaximum number of packages to return, sorted by self-time (default: 10)

how_to_collect How To Collect a CPU Profile

Returns a ready-to-run command and step-by-step recipe for capturing a V8 CPU profile, then loading it with load_profile. Use this when you do not yet have a .cpuprofile file. Choose the scenario that matches how the code runs.

ParameterTypeDescription
scenariostringHow the code under test runs. "next-server" (default) profiles a Next.js production server; "script" profiles a Next.js standalone server.js (or another Node entry).