javaperf MCP Server
io.github.theSharque/javaperf
Diagnose Java performance with AI: profile, analyze threads, and inspect JFR recordings via jcmd/jfr/jps.
What is the javaperf MCP server?
The javaperf MCP server enables AI assistants to profile Java applications and diagnose performance issues using JDK utilities (jcmd, jfr, jps). It provides tools to analyze threads, inspect JFR recordings, detect deadlocks, and examine memory and CPU hotspots without manual CLI usage.
javaperf bridges Java profiling tools and AI agents, letting Claude or Cursor analyze running Java processes directly. Use it to identify performance bottlenecks, memory leaks, GC inefficiency, thread contention, and CPU hotspots by capturing and parsing JFR recordings and live JVM diagnostics.
How to install javaperf
Copy-paste configuration for popular MCP clients.
Tools & capabilities
Tools this server exposes to the agent.
list_java_processes— List running Java processes with pid, mainClass, and arguments.start_profiling— Start JFR recording on a Java process with configurable duration, preset, memory size, and stack depth.stop_profiling— Stop JFR recording and save to file.list_jfr_recordings— List active JFR recordings for a process.parse_jfr_summary— Parse .jfr file into summary: top methods, GC stats, and anomalies.profile_memory— Memory profile: top allocators by bytes/count, allocation stacks, and OldObjectSample by class.profile_time— CPU bottleneck profile (bottom-up call tree).profile_frequency— Call frequency profile (leaf frames).profile_jfr_network— Socket I/O summary from .jfr (read/write operations).profile_jfr_file_io— File read/write summary from .jfr.profile_jfr_locks— Monitor contention and thread parking analysis.profile_jfr_native— Native-method CPU hotspots from .jfr.trace_method— Build call tree for a specific method from .jfr.gc_efficiency— GC efficiency analysis: pause time vs freed bytes per collector.analyze_threads— Thread dump with deadlock summary and optional structured lock-wait chains.check_deadlock— Check for Java-level deadlocks with structured output.heap_histogram— Class histogram showing instance and byte counts.heap_live_histogram_diff— Two histograms spaced by interval to detect memory growth.heap_dump— Create .hprof heap dump for analysis in MAT or VisualVM.heap_info— Brief heap summary.
Use cases
- Identify CPU hotspots and slow methods by profiling execution samples and building call trees.
- Detect memory leaks by comparing heap histograms over time and analyzing allocation stacks.
- Diagnose thread contention and deadlocks with lock analysis and thread dumps.
- Analyze GC efficiency and pause times to optimize garbage collection performance.
- Profile I/O operations (network, file, locks) to find performance bottlenecks in I/O-bound code.
javaperf MCP server FAQ
javaperf is an MCP server that exposes Java profiling tools (jcmd, jfr, jps) to AI assistants. It lets Claude or Cursor diagnose Java performance issues, analyze threads, detect deadlocks, and inspect JFR recordings without manual CLI usage.
Yes, javaperf is open-source and free. Install via npm: `npm install -g javaperf`.
Add the server to your MCP config file. For Cursor: Settings → Features → Model Context Protocol → Edit Config. For Claude Desktop: edit `claude_desktop_config.json` in your Claude config directory. Add: `{"mcpServers": {"javaperf": {"command": "npx", "args": ["-y", "javaperf"]}}}`.
Node.js v18+, and a JDK 8u262+ or 11+ with JFR support. JDK tools are auto-detected via JAVA_HOME or `which java`. If not found, set JAVA_HOME to your JDK root.
javaperf uses local jps/jcmd and only works on the machine where the MCP process runs. To diagnose a remote JVM, run the MCP server on that machine (e.g., via SSH remote workspace or Codespaces).
List processes → start profiling → wait → stop profiling → analyze with parse_jfr_summary, profile_memory, gc_efficiency, or profile_time. For memory leaks: heap_live_histogram_diff → start_profiling → profile_memory → heap_dump → Eclipse MAT.
README (reference)
Source of truth, from the repository.
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
{
"mcpServers": {
"javaperf": {
"command": "npx",
"args": ["-y", "javaperf"]
}
}
}
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)
# No installation needed - use directly in Cursor/Claude Desktop
# Just configure it as described in Integration section below
For Developers
- Clone the repository:
git clone https://github.com/theSharque/mcp-jperf.git
cd mcp-jperf
- Install dependencies:
npm install
- Build the project:
npm run build
Usage
Development Mode
npm run dev
Production Mode
npm start
MCP Inspector
Debug and test with MCP Inspector:
npx @modelcontextprotocol/inspector node dist/index.js
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:
{
"mcpServers": {
"javaperf": {
"command": "npx",
"args": ["-y", "javaperf"]
}
}
}
Option 2: Via npm link (Development)
For local development with live changes:
{
"mcpServers": {
"javaperf": {
"command": "javaperf"
}
}
}
Requires: cd /path/to/mcp-jperf && npm link -g
Option 3: Direct path
{
"mcpServers": {
"javaperf": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "${workspaceFolder}",
"env": {
"JAVA_HOME": "/path/to/your/jdk"
}
}
}
}
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):
{
"mcpServers": {
"javaperf": {
"command": "npx",
"args": ["-y", "javaperf"]
}
}
}
Continue.dev
Edit .continue/config.json:
{
"mcpServers": {
"javaperf": {
"command": "npx",
"args": ["-y", "javaperf"]
}
}
}
Tools
| Tool | Description |
|---|---|
list_java_processes | List running Java processes (pid, mainClass, args). Use topN (default 10) to limit. |
start_profiling | Start JFR. Pass pid, duration (seconds). Optional: preset (default effective: profile), settingsFile (path to .jfc, mutually exclusive with preset), memorysize, stackdepth (default 128). |
profile_jfr_network | Socket I/O summary from .jfr (jdk.SocketRead, jdk.SocketWrite). Optional filepath (default new_profile), topN. |
profile_jfr_file_io | File read/write summary (jdk.FileRead, jdk.FileWrite). Optional filepath, topN. |
profile_jfr_locks | Monitor contention (JavaMonitorBlocked) and j.u.c parking (ThreadPark). Optional filepath, topN. Live waits: analyze_threads structured=true. |
profile_jfr_native | Native-method CPU hotspots (jdk.NativeMethodSample). Optional filepath, topN. |
native_memory_summary | jcmd VM.native_memory summary — requires JVM with -XX:NativeMemoryTracking=summary or detail. Pass pid. |
gc_class_stats | jcmd GC.class_stats when available (often JDK 21+). Pass pid. |
gc_finalizer_info | jcmd GC.finalizer_info. Pass pid. |
compiler_codecache | jcmd Compiler.codecache. Pass pid. |
compiler_queue | jcmd Compiler.queue. Pass pid. |
list_jfr_recordings | List active JFR recordings for a process. Use before stop_profiling to get recordingId. |
stop_profiling | Stop recording and save to recordings/new_profile.jfr. Requires pid and recordingId. |
check_deadlock | Check for Java-level deadlocks. Returns structured JSON with threads, locks, and cycle. |
analyze_threads | Thread dump (jstack) with deadlock summary. Pass pid, optional topN (default 10), structured (JSON lock-wait chains). Live snapshot; historical locks: profile_jfr_locks. |
heap_histogram | Class histogram (GC.class_histogram). Pass pid, optional topN (20), all (triggers full GC — may pause app). Static snapshot; use heap_live_histogram_diff for growth. |
heap_live_histogram_diff | Two histograms spaced by intervalSeconds (default 5). Top classes by instance/byte growth. First step in memory-leak workflow. Pass pid, optional topN, all, minInstanceDelta. |
heap_dump | Create .hprof for MAT/VisualVM. After heap_live_histogram_diff, use MAT Path to GC Roots. Pass pid. Saved to recordings/heap_dump.hprof. |
heap_info | Brief heap summary. Pass pid. |
vm_info | JVM info: uptime, version, flags. Pass pid. |
trace_method | Build call tree for a method from .jfr. Pass className, methodName. Optional: filepath (default new_profile), topN. |
parse_jfr_summary | Parse .jfr into summary: top methods, GC stats, anomalies. Optional: filepath (default new_profile), events, topN. |
profile_memory | Memory profile: top allocators by bytes/count, allocation stacks, OldObjectSample by class. Optional: filepath, topN, sortBy (bytes/count). Pair with gc_efficiency, heap_live_histogram_diff. |
gc_efficiency | GC efficiency from .jfr: pause vs freed bytes per collector. Optional: filepath, topN. After stop_profiling. |
profile_time | CPU bottleneck profile (bottom-up). Optional: filepath (default new_profile), topN. |
profile_frequency | Call frequency profile (leaf frames). Optional: filepath (default new_profile), topN. |
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
Related MCP servers

mcp-architector
MCP server for architecture and system design. Store and manage project architecture locally.

1c-rest-mcp
AI agent access to 1C:Enterprise ERP data via OData 3.0—read and write catalogs, documents, and registers without configuration extensions.

io.github.theYahia/amocrm-mcp
MCP server for amoCRM API — leads, contacts, pipelines. Auth: Bearer token.

io.github.theYahia/bitrix24-mcp
MCP server for Bitrix24 CRM — deals, contacts, tasks via webhook API.

io.github.theYahia/boxberry-mcp
MCP server for Boxberry delivery API — city/point search, delivery calculation, tracking. 4 tools.
