javaperf
v1.4.3Java profiling MCP via jcmd/jfr/jps.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
list_java_processes
Lists all running Java processes on the machine. Returns an array of objects with pid, mainClass, and args. Use this tool first to discover the target process PID before calling start_profiling or analyze_threads. Data is obtained via jps -l -m.
| Parameter | Type | Description |
|---|---|---|
topN | integer | Maximum number of processes to return in the list. Default: 10. Use higher values if many Java processes are running. |
start_profiling
Starts JFR on the target PID. Rotates recordings (old_profile.jfr ← new_profile.jfr). Default preset is profile. Optional preset or settingsFile (.jfc, cwd-relative or absolute)—mutually exclusive. Builtin presets may omit socket/I/O/native/locks; use a custom .jfc for jdk.SocketRead/Write, FileRead/Write, JavaMonitorBlocked, jdk.ThreadPark, NativeMethodSample. Then list_jfr_recordings and stop_profiling.
| Parameter | Type | Description |
|---|---|---|
duration * | integer | Recording duration in seconds. Typical: 10–60 quick, 300+ under load. |
pid * | integer | Process ID of the Java application. Use list_java_processes. |
memorysize | string | JFR buffer size, e.g. 20M. Default JVM buffer applies if omitted. |
preset | string | Builtin settings name (e.g. profile, default). Effective default when omitted is profile. Mutually exclusive with settingsFile. |
settingsFile | string | Path to .jfc file (cwd-relative or absolute). Mutually exclusive with preset. |
stackdepth | integer | Stack depth for JFR events. Default 128. |
stop_profiling
Stops an active JFR recording and saves it to recordings/new_profile.jfr. Use recordings/new_profile.jfr for current data, recordings/old_profile.jfr for previous (before/after comparison).
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java process that has the active recording. Must match the pid used in start_profiling. |
recordingId * | string | ID of the recording to stop. This is the recordingId returned by start_profiling (e.g. '1' or '2'). |
check_deadlock
Checks for Java-level deadlocks in the specified process. Parses jcmd Thread.print output and returns structured JSON: which threads are involved, what locks they hold/wait for, and the deadlock cycle. Use for automated analysis and reports.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
list_jfr_recordings
Lists active and recent JFR recordings for a Java process (jcmd JFR.check). Returns recording id, duration, state (running/stopped), and filename. Use before stop_profiling to get the correct recordingId.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
analyze_threads
Thread dump (jstack -l). Default: plain text. Set structured=true for JSON lock-wait chains (live snapshot). Historical contention: profile_jfr_locks. Deadlock cycle: check_deadlock.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
structured | boolean | Return structured JSON with lockWaitChains instead of plain-text dump. Default: false. |
topN | integer | Maximum number of threads to include in the output. Default: 10. Increase for applications with many threads. |
heap_histogram
Static class histogram (jcmd GC.class_histogram). For live growth over time use heap_live_histogram_diff instead.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
all | boolean | Include unreachable objects. Triggers full GC and may cause application pause. |
topN | integer | Maximum number of top classes to return. Default: 20. |
heap_live_histogram_diff
Two GC.class_histogram snapshots spaced by intervalSeconds; returns classes whose instance count grew most. Use first in memory-leak workflow; then profile_memory and heap_dump (MAT path-to-GC-roots). Each snapshot walks the heap and may pause the app.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID from list_java_processes. |
all | boolean | Include unreachable objects (-all). Triggers full GC and may pause the app. |
intervalSeconds | integer | Seconds between baseline and snapshot histograms. Default: 5. |
minInstanceDelta | integer | Ignore classes with instance growth below this threshold. |
topN | integer |
heap_dump
Creates .hprof for Eclipse MAT / VisualVM. After heap_live_histogram_diff picks a growing class, use MAT Path to GC Roots (exclude weak/soft). Saved to recordings/heap_dump.hprof. Warning: large file.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
heap_info
Brief heap usage summary: capacities, used, committed regions. Quick snapshot without full dump.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
vm_info
JVM information: uptime, version, and flags. Useful for environment verification.
| Parameter | Type | Description |
|---|---|---|
pid * | integer | Process ID of the Java application. Get this from list_java_processes. |
trace_method
Builds a call tree for a specific method from a .jfr file. Filters ExecutionSample events to find stack traces containing the given class and method, then aggregates call paths. Use when you want to see who calls a particular method and from where. Limitation: JFR sampling (~10 ms) may miss very fast methods.
| Parameter | Type | Description |
|---|---|---|
className * | string | Fully qualified class name (e.g. com.example.MyService) or a substring to match. Used to filter stack frames. |
methodName * | string | Method name to search for (e.g. processRequest). Matches the method in the stack trace. |
events | array | Optional list of JFR event types to parse. Default: jdk.ExecutionSample. Advanced users can specify other event types. |
filepath | string | Path to .jfr file. Shortcuts: 'new_profile' (current, default) or 'old_profile' (previous). Or full path e.g. recordings/new_profile.jfr. |
topN | integer | Maximum number of call paths (branches) to return in the call tree. Default: 10. |
parse_jfr_summary
Parses a .jfr file and returns a structured summary: top methods by CPU samples, GC statistics, thread allocation stats, and anomaly hints (e.g. high GC count). Use for a quick high-level overview of the recording before diving into specific profiles.
| Parameter | Type | Description |
|---|---|---|
events | array | Optional list of JFR event types to include. Default: jdk.ExecutionSample, jdk.GarbageCollection, jdk.JavaThreadStatistics, jdk.ThreadAllocationStatistics. |
filepath | string | Path to .jfr file. Shortcuts: 'new_profile' (current, default) or 'old_profile' (previous). Or full path e.g. recordings/new_profile.jfr. |
topN | integer | Maximum number of top methods to include in the summary. Default: 10. |
profile_memory
JFR memory profile: top allocators by bytes/count, allocation stacks, OldObjectSample by class (allocation site, not GC roots). Pair with heap_live_histogram_diff, gc_efficiency, heap_dump+MAT. Requires profile preset recording.
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to .jfr file. Shortcuts: 'new_profile' (current, default) or 'old_profile' (previous). Or full path e.g. recordings/new_profile.jfr. |
sortBy | string | Primary ranking for topAllocators. Default: bytes. |
topN | integer | Maximum number of top allocators to return. Default: 10. |
gc_efficiency
GC efficiency from .jfr: pause time vs freed bytes per collector/cause. Use after stop_profiling; complements profile_memory and heap_info. Not a general JFR summary (see parse_jfr_summary).
| Parameter | Type | Description |
|---|---|---|
filepath | string | |
topN | integer |
profile_time
CPU time (bottleneck) profile from a .jfr file. Uses bottom-up aggregation: each method is counted in every sample where it appears in the stack, including time spent in callees. Returns methods consuming the most CPU time. Use when the goal is to find performance bottlenecks and slow code paths.
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to .jfr file. Shortcuts: 'new_profile' (current, default) or 'old_profile' (previous). Or full path e.g. recordings/new_profile.jfr. |
topN | integer | Maximum number of top methods by CPU time to return. Default: 10. |
profile_frequency
Call frequency profile from a .jfr file. Counts methods that appear at the leaf (top) of the stack in ExecutionSample events — i.e. methods that were actively executing when sampled. Returns the most frequently sampled methods (exclusive, not cumulative). Use when looking for hot spots or the most often executed code paths.
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to .jfr file. Shortcuts: 'new_profile' (current, default) or 'old_profile' (previous). Or full path e.g. recordings/new_profile.jfr. |
topN | integer | Maximum number of top methods by call frequency to return. Default: 10. |
profile_jfr_network
Summarize JDK socket I/O from a .jfr (jdk.SocketRead, jdk.SocketWrite): event counts, total bytes read/written where available, top endpoints (host:port / address), and cumulative stack hotspots. Recording must include those events (custom .jfc or preset that enables them). If emptyEvents, use start_profiling settingsFile.
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to .jfr. Shortcuts: new_profile, old_profile, or absolute path. |
topN | integer | Top N endpoints and methods. |
profile_jfr_file_io
Summarize file read/write events (jdk.FileRead, jdk.FileWrite): counts, bytes, top paths, stack hotspots. Events must exist in recording; configure via start_profiling preset or settingsFile (.jfc).
| Parameter | Type | Description |
|---|---|---|
filepath | string | Path to .jfr. Shortcuts: new_profile, old_profile. |
topN | integer | Top N paths/methods. |
profile_jfr_locks
Lock contention from JFR: synchronized monitors (JavaMonitorBlocked) and j.u.c parking (ThreadPark). Live wait chains: analyze_threads structured=true. Deadlocks: check_deadlock. Enable events via custom .jfc if missing.
| Parameter | Type | Description |
|---|---|---|
filepath | string | |
topN | integer |
profile_jfr_native
CPU-style cumulative hotspots from jdk.NativeMethodSample stacks. Recording must enable NativeMethodSample (often requires custom .jfc).
| Parameter | Type | Description |
|---|---|---|
filepath | string | |
topN | integer |
native_memory_summary
jcmd VM.native_memory summary=true. Requires JVM started with -XX:NativeMemoryTracking=summary or detail; otherwise explains how to enable.
| Parameter | Type | Description |
|---|---|---|
pid * | integer |
gc_class_stats
jcmd GC.class_stats (class loader / metaspace style stats where supported—often JDK 21+). On older JDK returns error hint; use heap_info or heap_histogram instead.
| Parameter | Type | Description |
|---|---|---|
pid * | integer |
gc_finalizer_info
jcmd GC.finalizer_info — finalizer queue diagnostics for the live process.
| Parameter | Type | Description |
|---|---|---|
pid * | integer |
compiler_codecache
jcmd Compiler.codecache — code heap usage and related JVM output.
| Parameter | Type | Description |
|---|---|---|
pid * | integer |
compiler_queue
jcmd Compiler.queue — methods queued for JIT compilation.
| Parameter | Type | Description |
|---|---|---|
pid * | integer |