
javaperf
io.github.theSharque由 GitHub 账号 theSharque 发布v1.4.2更新于 Oct 24, 2026
Java profiling MCP via jcmd/jfr/jps. Diagnose performance, analyze threads, inspect JFR recordings.
概览
本地 MCP 服务器,借助 JDK 的 jps、jcmd、jfr 工具,让助手对运行中的 Java 应用做性能剖析与诊断。
- 可以做什么
- 列出运行中的 Java 进程,查看 JVM 信息、运行时长、版本与启动参数
- 启动、列出并停止 JFR 录制,再把录制解析为摘要、CPU、调用频率、内存、GC、网络、文件 I/O、锁与原生方法剖析
- 生成线程转储、检测死锁并分析锁等待链
- 检查堆:类直方图、增长对比、堆转储与堆摘要
- 执行 jcmd 诊断:原生内存、GC 类统计、终结器、编译器代码缓存与编译队列
- 从录制中构建某个方法的调用树
- 适用场景
- 适合在同一台机器上排查 Java 性能问题:CPU 占用高、内存泄漏、GC 压力、锁竞争、死锁或 I/O 缓慢,无需手动敲 jcmd 和 jfr 命令。
- 运行要求
- 以本地 stdio 进程运行,通常通过 npx 从 npm 包 javaperf 启动。需要 Node.js v18+ 以及支持 JFR 的 JDK(8u262+ 或 11+);jps、jcmd、jfr 通过 JAVA_HOME 或 PATH 查找,必要时需在服务器配置中设置 JAVA_HOME。必须与目标 JVM 在同一主机、以同一操作系统用户运行。
安装
在 SourceWeft 中
- 打开 控制台中的 javaperf,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
javaperf
MCP (Model Context Protocol) server for profiling Java applications via JDK utilities (jcmd, jfr, jps)
Enables AI assistants to diagnose performance, analyze threads, and inspect JFR recordings without manual CLI usage.
📦 Install: npm install -g javaperf or use via npx
🌐 npm: https://www.npmjs.com/package/javaperf
How to connect to Claude Desktop / IDE
Add the server to your MCP config. Example for claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
For Cursor IDE: Settings → Features → Model Context Protocol → Edit Config, then add the same block inside mcpServers. See the Integration section for more options (local dev, custom JAVA_HOME, etc.).
Requirements
- Node.js v18+
- JDK 8u262+ or 11+ with JFR support
JDK tools (jps, jcmd, jfr) are auto-detected via JAVA_HOME or which java. If not found, set JAVA_HOME to your JDK root.
Quick Start
For Users (using npm package)
For Developers
- Clone the repository:
- Install dependencies:
- Build the project:
Usage
Development Mode
Production Mode
MCP Inspector
Debug and test with MCP Inspector:
Integration
Cursor IDE
- Open Cursor Settings → Features → Model Context Protocol
- Click "Edit Config" button
- Add one of the configurations below
Option 1: Via npm (Recommended)
Installs from npm registry automatically:
Option 2: Via npm link (Development)
For local development with live changes:
Requires: cd /path/to/mcp-jperf && npm link -g
Option 3: Direct path
If list_java_processes fails with "jps not found", the MCP server may not inherit your shell's JAVA_HOME. Add the env block above with your JDK root path (e.g. /usr/lib/jvm/java-17 or ~/.sdkman/candidates/java/current).
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Continue.dev
Edit .continue/config.json:
Tools
Example Workflow
- List processes →
list_java_processes - Start recording →
start_profilingwithpidandduration(e.g. 60) - Wait for
durationseconds (or let it run) - Check recordings (optional) →
list_jfr_recordingsto getrecordingId - Stop and save →
stop_profilingwithpidandrecordingId - Analyze →
parse_jfr_summary,profile_memory,gc_efficiency,profile_time,profile_frequency,trace_method,profile_jfr_network,profile_jfr_file_io,profile_jfr_locks, orprofile_jfr_native(events must exist in the recording — usestart_profilingwith a suitable preset or.jfcviasettingsFile)
Example Workflow: Memory leak hypothesis
- List processes →
list_java_processes - Find growing classes →
heap_live_histogram_diffwithpid,intervalSeconds: 5 - Record under load →
start_profiling→ wait →stop_profiling - Allocation profile →
profile_memoryonnew_profile(checkoldObjectSamplesByClassfor suspect class) - GC pressure →
gc_efficiencyon the same.jfr - Confirm retention →
heap_dump→ Eclipse MAT → Path to GC Roots (exclude weak/soft references) - AI builds a coherent leak hypothesis from the combined results (no dedicated tool)
Remote JVM (stdio MCP)
javaperf uses stdio MCP and attaches to JVMs via local jps/jcmd. That only works on the OS account and host where the MCP process runs.
To diagnose a JVM on another machine:
- Run the MCP server (your IDE connector, Cursor, or Claude Desktop) on that machine, for example SSH remote workspace, Codespaces, CI runner checkout on the server, or a shell session on the same host as the process.
- Do not rely on piping
jcmdover plain SSH from another host unless you deliberately run MCP there; attaching across hosts is outside this server’s scope.
Requirements (same user, local attach) listed under Limitations still apply.
Limitations
- Sampling: JFR samples ~10ms; fast methods may not appear in ExecutionSample
- Local only: Runs on the machine where MCP is started
- Permissions: Must run as same user as target JVM for jcmd access
来源:README.md,提交 9d97a88
工具
0版本历史
2- v1.4.2最新Sep 27, 2026
- v1.4.1Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。