Perfonext Profiler MCP

io.github.souvikdu由 GitHub 账号 souvikdu 发布v0.7.3更新于 Oct 24, 2026

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

已验证STDIO仅桌面开发者工具数据与分析

概览

AI 生成的概览

本地 MCP 服务器,加载 V8/Chrome CPU 性能分析文件,为助手提供热点排名、按 npm 包统计的开销和带源码标注的热点行。

可以做什么
加载并汇总性能分析文件:解析 .cpuprofile 文件或含 CPU 数据的 Chrome trace 导出,列出已加载的配置,并先给出采集配置的操作步骤。热点排名:按自身耗时列出最耗时的函数,并标注所属 npm 包或用户代码。解释函数:展示耗时、调用方与被调用方,可选附带按 V8 采样数标注的源码行。按 npm 包汇总自身耗时,找出开销最大的依赖。比较两份配置以发现性能回退,并针对热点函数给出结构化的优化建议。
适用场景
在为 Next.js 服务器或 Node 脚本做性能分析时适用:希望助手直接解读 CPU 配置,而不是读取数兆字节的原始转储,例如查找热点、定位昂贵依赖,或对比基线配置与新配置。
运行要求
作为 stdio 服务器在本地运行,通过 npx 启动 npm 包 @perfonext/profiler-mcp,因此需要 Node.js 和 npm。未声明认证、环境变量或请求头。磁盘上需已有 .cpuprofile 文件或 Chrome trace 导出。
安装前请注意
读取源码的工具会访问磁盘文件;仅能读取当前工作目录内的文件,其他路径会被拒绝。性能分析文件及从中读取的源码行会传给所连接的助手,因此不要对不希望与该客户端共享的代码做分析。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Perfonext Profiler MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

perfonext-profiler-mcp

Analyze V8 and Chrome CPU profiles to find hotspots in Next.js servers and scripts.

[npm] [npm downloads] [license] [website]

perfonext-profiler-mcp is a Model Context Protocol (MCP) server that gives GitHub Copilot, Claude Desktop, Claude Code, and other MCP clients structured CPU profiling data for Next.js performance work. It loads V8 and Chrome CPU profiles and turns them into hotspot rankings, per-package costs, and source-annotated hot lines — evidence agents can reason over instead of ingesting multi-megabyte profile dumps.

Quick Start

perfonext-profiler-mcp is a standard MCP stdio server, so it works with any MCP-compatible client (GitHub Copilot in VS Code, Claude Desktop, Claude Code, Cursor, and others). Run it directly with npx:

bash
npx -y @perfonext/profiler-mcp

Or install globally:

bash
npm install -g @perfonext/profiler-mcp

The executable command remains perfonext-profiler-mcp after installation.

VS Code

Add the server to .vscode/mcp.json (the workspace MCP configuration file):

json
{  "servers": {    "perfonext-profiler": {      "type": "stdio",      "command": "npx",      "args": ["-y", "@perfonext/profiler-mcp"]    }  }}

Reload the VS Code window and run MCP: List Servers to start it, or accept the trust prompt when it appears.

Claude Desktop

Add the server to claude_desktop_config.json:

json
{  "mcpServers": {    "perfonext-profiler": {      "command": "npx",      "args": ["-y", "@perfonext/profiler-mcp"]    }  }}

Restart Claude Desktop to pick up the new server.

Claude Code

Add the server with the CLI:

bash
claude mcp add perfonext-profiler -- npx -y @perfonext/profiler-mcp

Or add the same mcpServers entry to .mcp.json.

Other MCP clients

Any client that supports stdio MCP servers can launch npx -y @perfonext/profiler-mcp. Consult your client's documentation for its MCP server configuration format.

For a locally-built checkout, point command/args at node and the repo's dist/index.js instead.

Troubleshooting

spawn npx ENOENT / spawn node ENOENT on macOS with nvm

If the server fails to start with this error, your GUI MCP client likely cannot see nvm. GUI apps on macOS do not load shell config (.zshrc/.bashrc), so nvm-installed npx/node are not on PATH. Use an absolute npx path and include the same Node directory in PATH:

json
{  "servers": {    "perfonext-profiler": {      "type": "stdio",      "command": "/Users/YOU/.nvm/versions/node/v<version>/bin/npx",      "args": ["-y", "@perfonext/profiler-mcp"],      "env": {        "PATH": "/Users/YOU/.nvm/versions/node/v<version>/bin:/usr/bin:/bin"      }    }  }}

Merge these fields into your client's server entry, under servers for VS Code or mcpServers for Claude Desktop/Code. Then ask your assistant: "How do I capture a CPU profile of my Next.js server?"

What It Does

  • loads .cpuprofile files and Chrome trace exports that contain CPU profile data
  • identifies the hottest functions by self time, annotated with the originating npm package
  • explains caller and callee relationships for a selected function
  • reads actual source code for hot functions and annotates each line with V8 sample counts (v0.2.0)
  • aggregates CPU self-time per npm package to find expensive third-party dependencies (v0.3.0)
  • compares two profiles to surface regressions and improvements
  • returns deterministic optimization suggestions for common hotspots
  • summarizes loaded profiles so an MCP client can keep context tight

Tools

ToolDescription
how_to_collectReturn a ready-to-run command and step-by-step recipe for capturing a .cpuprofile, then loading it. Use this when you don't have a profile yet
load_profileParse and load a .cpuprofile file or Chrome trace export from disk
get_hotspotsFind top functions by self-time. Each entry includes a package field identifying the npm package or (user code)
explain_functionExplain a function's timing, callers, and callees. Pass includeSource: true to attach annotated source lines
read_source_contextRead the actual source file for a hot function and annotate each line with tick counts from positionTicks
get_package_costsAggregate CPU self-time by npm package — shows which dependencies are most expensive
compare_profilesCompare two profiles and highlight regressions
suggest_optimizationsGenerate structured, multi-pattern optimization suggestions for hot functions. Detects high fan-in, recursion, dominant callers, and V8-specific patterns. Deduplicates functions split across multiple call sites
get_profile_summarySummarize one profile or list all loaded profiles

Every tool result carries a nextStep breadcrumb pointing at the natural follow-up call, so an MCP client can walk the collect → analyze → fix loop without guessing.

Example Prompts

  • "How do I capture a CPU profile of my Next.js server?"
  • "Load the CPU profile at ./profile.cpuprofile and show me the top hotspots."
  • "Which npm packages are consuming the most CPU in this profile?"
  • "Explain why processData is expensive in the loaded profile."
  • "Show me the actual source lines for processData and mark which lines are hottest."
  • "Explain transformResult and include the annotated source code."
  • "Compare my baseline and current CPU profiles and tell me what got slower."
  • "Suggest optimizations for the top three hotspots."

Deep Tool Reference

Per-tool input/output schemas and manual profile capture

how_to_collect details

jsonc
// Input{ "scenario": "next-server" } // or "script"; defaults to "next-server"
// Output{  "scenario": "next-server",  "summary": "Profile a production Next.js server while it handles a single request. ...",  "command": "node --cpu-prof --cpu-prof-dir=./.perf-profiles ./node_modules/next/dist/bin/next start",  "steps": [ "...", "load_profile({ filePath: \"./.perf-profiles/<file>.cpuprofile\" })" ],  "outputDir": "./.perf-profiles",  "nextStep": "After stopping the server, call load_profile with the .cpuprofile ..."}

next-server profiles a production Next.js server while it serves a single request. If next start says standalone output is unsupported, use the script scenario with .next/standalone/server.js. script profiles that standalone server (or another Node entry). Keep the scenario to one route and one hit. Node writes one .cpuprofile per process/worker thread into the output directory. The Next server command uses Node CLI flags (not NODE_OPTIONS) so it is the same on Unix and Windows.

read_source_context details

jsonc
// Input{ "profileId": "<id>", "functionName": "myFn", "contextLines": 10 }
// Output (per line){  "lineNumber": 42,  "content": "  for (let i = 0; i < items.length; i++) {",  "ticks": 18,      // V8 samples that landed on this line  "isHot": true     // true when ticks >= 50% of peak ticks for this function}

The returned window is sized to cover the function's actual hot lines, not just a fixed radius around its declaration — a function's real bottleneck is often well past its function line. contextLines (default 10) sets the minimum padding around both the declaration and the hot lines; if any ticks still fall outside the returned window, the top-level result includes hiddenTicks (a count) and a warning telling you to retry with a larger contextLines. explain_function also accepts contextLines when called with includeSource: true.

Only files inside the current working directory can be read. file:// URLs and absolute paths are both handled; http://, node: builtins, and paths outside the project root are rejected.

suggest_optimizations details

jsonc
// Input{ "profileId": "<id>", "limit": 5 }
// Output (per function){  "function": "processData",  "file": "file:///app/src/processor.js",  "line": 10,  "selfPercent": "18.2%",  "patterns": [    {      "pattern": "high-fan-in",      "detail": "Called from 6 distinct call sites (e.g. renderRow, buildTree, …)",      "suggestion": "This function is a shared hot path. Ensure it is well-optimised and monomorphic …"    },    {      "pattern": "hot-caller",      "detail": "84% of calls come from \"renderRow\"",      "suggestion": "Focus optimisation effort on \"renderRow\" rather than this function …"    }  ],  "topSuggestion": "This function is a shared hot path …"}

Patterns detected (multiple can fire for the same function):

PatternTrigger
gc-pressureFunction name matches GC/Scavenge/MarkCompact
json-serializationJSON.parse / JSON.stringify
regex-costRegExp / exec / test calls
v8-deoptCompile / Recompile / Optimize / Deoptimize
high-fan-in≥ 3 distinct parent call sites
recursionFunction appears in its own descendant sub-tree
hot-callerOne caller accounts for ≥ 80% of call-site occurrences
cpu-boundFallback when no other pattern matches

Functions that appear at multiple call sites are automatically merged before ranking so the same logical function is only reported once.

get_package_costs details

jsonc
// Input{ "profileId": "<id>", "limit": 10 }
// Output (per package){  "rank": 1,  "package": "lodash",  "selfTime": "42.3ms",  "selfPercent": "14.1%",  "totalTimeIncludingCallbacks": "58.0ms",  "totalPercentIncludingCallbacks": "19.3%",  "topFunctions": [    { "function": "chunk", "file": "lodash/chunk.js", "line": 41, "selfTime": "28.0ms", "selfPercent": "9.3%" }  ]}

selfTime is the time spent inside the package's own code. totalTimeIncludingCallbacks also counts everything the package called into — including your own callbacks handed back to it — so it can exceed what removing the package would actually save.

Scoped packages (@babel/core, @next/env, etc.) are handled correctly. User code and native builtins (no node_modules in the path) are excluded.

Generating a CPU Profile

Ask Copilot to call how_to_collect for a ready-to-run recipe, or generate one manually:

Next.js production server (profile a single request):

bash
node --cpu-prof --cpu-prof-dir=./.perf-profiles ./node_modules/next/dist/bin/next start# hit the route once, then stop the process so it can exit and write the profile

If next start reports that standalone output is unsupported:

bash
node --cpu-prof --cpu-prof-dir=./.perf-profiles .next/standalone/server.js

Chrome DevTools:

  1. Open DevTools and go to the Performance tab.
  2. Record the scenario you want to inspect.
  3. Stop recording and save the result as a .cpuprofile export.

Related Perfonext Tools

Development

bash
npm installnpm run buildnpm test

The repository already includes sample fixtures under tests/fixtures/ for local validation.

License

MIT

来源:README.md,提交 c6ff838

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.7.3最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分