Troubleshooting & Error Handling
This guide covers common connection issues, error codes, and operational fixes for jfr-performance-mcp.
Standard Error Payload Format
When an MCP tool invocation encounters an invalid argument or environment issue, jfr-performance-mcp returns a structured error object conforming to the MCP specification:
{
"isError": true,
"errorCode": "RECORDING_NOT_FOUND",
"message": "Recording 'cpu-run.jfr' was not found in directory '/path/to/recordings'."
}
Error Code Catalog
RECORDING_NOT_FOUND
- Cause: The requested
.jfrfile does not exist in the configured directory. - Remedy:
- Verify the filename passed to the tool.
- Invoke
list_recordingsto verify which files are present. - Verify that
JFR_RECORDINGS_DIRpoints to the directory containing your recordings.
RECORDING_ACCESS_DENIED
- Cause: The path contains relative traversal sequences (
../) or attempts to follow a symlink outside the allowed directory tree. - Remedy: Pass only the relative filename within
JFR_RECORDINGS_DIR(e.g.,cpu-hotspot-faulty.jfr, not../../recordings/cpu-hotspot-faulty.jfr).
INVALID_RECORDING
- Cause: The file is empty, partially written, or not a valid Java Flight Recorder binary format.
- Remedy:
- Ensure the JVM process that generated the recording has fully flushed and stopped the recording.
- Test opening the file in JDK Mission Control (
jmc <filename>) to verify file integrity.
INVALID_ARGUMENT
- Cause: A required parameter is missing or out of bounds (e.g.
topN: -5or missingrecording). - Remedy: Review the parameter definitions in the MCP Tools Reference.
INTERNAL_ERROR
- Cause: An unhandled runtime exception occurred within the parser engine.
- Remedy: Check the client's STDERR console log. Detailed stack traces are emitted to
STDERRwithout polluting the JSON-RPC stream.
Operational Troubleshooting
MCP Client Hangs or Times Out on Startup
- Verify Java 21+ on
PATH: Runjava -versionin your terminal. If your IDE launches with a system default Java 17 or 11, specify the full path to the Java 21 binary in your client config:"command": "/usr/lib/jvm/temurin-21-jdk/bin/java" - Verify JAR Exists: Ensure the path to
jfr-performance-mcp-1.0.0.jaris an absolute path.
JSON-RPC Parser Error in Client Console
- Symptom: Client reports "SyntaxError: Unexpected token in JSON at position 0".
- Root Cause: A log message or JVM warning was written to
STDOUT. - Remedy:
- Verify that
logback.xmlroutes console output strictly toSystem.err. - Avoid passing JVM flags like
-verbose:classor-XX:+PrintCommandLineFlagsthat print directly toSTDOUT.
- Verify that
High Memory Usage or OutOfMemoryError on Large Recordings
- Symptom: The server process terminates with
java.lang.OutOfMemoryError: Java heap spacewhen reading recordings > 500 MB. - Remedy: Increase the max heap limit in the client configuration args:
"args": ["-Xms1g", "-Xmx4g", "-jar", "/path/to/jfr-performance-mcp-1.0.0.jar"]