
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 分
請在儲存庫或註冊中心條目中宣告授權條款。