karellen-jdb-mcp
v0.1.2MCP Server for JDB (Java Debugger)
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
jdb_connect
Connect to a running JVM via JDWP. Returns the port as the session handle. The JVM must be started with JDWP enabled, e.g.: java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:<port> ... Multiple sessions can be active simultaneously on different ports. When only one session is active, other tools auto-resolve it. When multiple are active, pass port= to each tool to select the session. Args: jdb_path: Path to the jdb executable (default: "jdb" from PATH). host: Host where the JVM is listening (default: localhost). port: JDWP d…
| Parameter | Type | Description |
|---|---|---|
classpath | string | |
host | string | |
jdb_path | string | |
port | integer | |
sourcepath | string | |
trackallthreads | boolean | |
wait_timeout | integer |
jdb_disconnect
Disconnect from the JVM and clean up the JDB session. Args: port: Port of the session to disconnect. Optional if only one session is active.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_session_list
List all active JDB debug sessions.
jdb_version
Get JDB version information and available features. Args: port: Port of the session to query. Optional if only one session is active.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_launch
Launch a JVM process with JDWP debug support on a random available port. Use ${JDB_PORT} in the command to reference the allocated port. It will be substituted before launch. The process runs in the background. After launching, use jdb_connect(port=<returned port>, wait_timeout=30) to attach the debugger. Args: command: Command as a list of strings. Use ${JDB_PORT} where the debug port should appear. Examples: ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:${JDB_PORT}", "-cp", "target/classes", "com.…
| Parameter | Type | Description |
|---|---|---|
command * | array | |
env | object | |
working_directory | string |
jdb_launch_list
List all launched JVM processes with their status.
jdb_launch_status
Get the status of a launched JVM process. Args: port: The port returned by jdb_launch.
| Parameter | Type | Description |
|---|---|---|
port * | integer |
jdb_launch_stop
Stop a launched JVM process. Args: port: The port returned by jdb_launch.
| Parameter | Type | Description |
|---|---|---|
port * | integer |
jdb_run
Start execution of the application's main class. Args: class_name: Main class to run (usually auto-detected from JVM). args: Command-line arguments for the application.
| Parameter | Type | Description |
|---|---|---|
args | string | |
class_name | string | |
port | integer |
jdb_cont
Continue execution until the next breakpoint, exception, or program exit.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_step
Step into: execute current line, stepping into method calls.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_next
Step over: execute current line, stepping over method calls.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_step_up
Step out: execute until the current method returns to its caller.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_wait_for_event
Wait for a stop event from a previously resumed execution. Call this after jdb_cont or jdb_run when they return reason="resumed" (meaning the JVM resumed execution but no breakpoint/exception was hit within the initial window). This tool blocks until a stop event occurs (breakpoint hit, exception thrown, program exit) or the timeout expires. Args: timeout: Maximum seconds to wait for an event (default: 120). port: Port of the session. Optional if only one session is active.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
timeout | integer |
jdb_breakpoint_set
Set a breakpoint at a class:line or class.method location. Args: location: Breakpoint location. Use "com.example.MyClass:42" for a line breakpoint, or "com.example.MyClass.myMethod" (or with arg types: "com.example.MyClass.myMethod(int,java.lang.String)") for a method breakpoint. thread_id: Only stop in this thread (JDK 13+ only). suspend_policy: "go" (don't suspend), "thread" (suspend only event thread), or omit for default (suspend all). JDK 13+ only.
| Parameter | Type | Description |
|---|---|---|
location * | string | |
port | integer | |
suspend_policy | string | |
thread_id | string |
jdb_breakpoint_clear
Clear a breakpoint at a class:line or class.method location. Args: location: Same format as jdb_breakpoint_set.
| Parameter | Type | Description |
|---|---|---|
location * | string | |
port | integer |
jdb_breakpoint_list
List all currently set breakpoints.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_catch
Break when a specified exception is thrown. Args: class_pattern: Exception class name or pattern (e.g. "java.lang.NullPointerException", "java.io.*"). Use "*" for all exceptions. filter_type: "caught", "uncaught", or "all" (default).
| Parameter | Type | Description |
|---|---|---|
class_pattern * | string | |
filter_type | string | |
port | integer |
jdb_ignore
Cancel a previous exception breakpoint set with jdb_catch. Args: class_pattern: Exception class name or pattern to stop catching. filter_type: "caught", "uncaught", or "all" (default).
| Parameter | Type | Description |
|---|---|---|
class_pattern * | string | |
filter_type | string | |
port | integer |
jdb_watch
Watch access or modifications to a field. Args: class_field: Fully qualified field (e.g. "com.example.MyClass.myField"). access_type: "modification" (default, write only), "access" (read only), or "all" (both read and write).
| Parameter | Type | Description |
|---|---|---|
class_field * | string | |
access_type | string | |
port | integer |
jdb_unwatch
Remove a field watchpoint. Args: class_field: Fully qualified field (e.g. "com.example.MyClass.myField"). access_type: Must match the type used when the watchpoint was set.
| Parameter | Type | Description |
|---|---|---|
class_field * | string | |
access_type | string | |
port | integer |
jdb_threads
List all threads, grouped by thread group. Args: thread_group: Show only threads in this group. If omitted, shows all.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread_group | string |
jdb_thread
Set the default thread for subsequent commands. Args: thread_id: Thread ID (from jdb_threads output, e.g. "0x1a8" or a number).
| Parameter | Type | Description |
|---|---|---|
thread_id * | string | |
port | integer |
jdb_suspend
Suspend threads. If no thread IDs given, suspends all threads. Args: thread_ids: List of thread IDs to suspend. Omit to suspend all.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread_ids | array |
jdb_resume
Resume threads. If no thread IDs given, resumes all threads. Args: thread_ids: List of thread IDs to resume. Omit to resume all.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread_ids | array |
jdb_where
Get the call stack (stack trace) for a thread. Args: thread_id: Thread ID. If omitted, shows current thread's stack. Use "all" to show all threads' stacks.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread_id | string |
jdb_up
Move up the call stack (toward the caller). Args: count: Number of frames to move up (default: 1).
| Parameter | Type | Description |
|---|---|---|
count | integer | |
port | integer |
jdb_down
Move down the call stack (toward the callee). Args: count: Number of frames to move down (default: 1).
| Parameter | Type | Description |
|---|---|---|
count | integer | |
port | integer |
jdb_print
Print the value of an expression. Supports fields, locals, method calls, arithmetic, and new expressions. Args: expression: Java expression to evaluate (e.g. "myVar", "obj.field", "obj.method()", "arr[0]", "i + j").
| Parameter | Type | Description |
|---|---|---|
expression * | string | |
port | integer |
jdb_dump
Dump an object, showing all its fields (both static and instance). More detailed than jdb_print for object inspection. Args: expression: Expression that evaluates to an object.
| Parameter | Type | Description |
|---|---|---|
expression * | string | |
port | integer |
jdb_eval
Evaluate a Java expression (alias for jdb_print). Args: expression: Java expression to evaluate.
| Parameter | Type | Description |
|---|---|---|
expression * | string | |
port | integer |
jdb_set
Assign a new value to a variable, field, or array element. Args: lvalue: Target to assign to (e.g. "myVar", "obj.field", "arr[0]"). expression: Value expression (e.g. "42", '"hello"', "new Object()").
| Parameter | Type | Description |
|---|---|---|
expression * | string | |
lvalue * | string | |
port | integer |
jdb_locals
List all local variables and their values in the current stack frame.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_classes
List all currently loaded classes in the JVM.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_class_info
Show details of a class (superclass, interfaces, etc.). Args: class_id: Fully qualified class name (e.g. "com.example.MyClass").
| Parameter | Type | Description |
|---|---|---|
class_id * | string | |
port | integer |
jdb_methods
List all methods of a class. Args: class_id: Fully qualified class name.
| Parameter | Type | Description |
|---|---|---|
class_id * | string | |
port | integer |
jdb_fields
List all fields of a class. Args: class_id: Fully qualified class name.
| Parameter | Type | Description |
|---|---|---|
class_id * | string | |
port | integer |
jdb_list
List source code around the current execution point or a specific location. Args: location: Optional line number or method name to list around.
| Parameter | Type | Description |
|---|---|---|
location | string | |
port | integer |
jdb_sourcepath
Display or change the source path for finding .java source files. Args: path: New source path (colon-separated directories). If omitted, shows current.
| Parameter | Type | Description |
|---|---|---|
path | string | |
port | integer |
jdb_classpath
Print the classpath information from the target JVM.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_lock
Print lock/monitor information for an object (owner, waiting threads). Useful for deadlock analysis. Args: expression: Expression evaluating to an object to inspect.
| Parameter | Type | Description |
|---|---|---|
expression * | string | |
port | integer |
jdb_threadlocks
Print lock information for a thread (owned monitors, lock being waited on). Useful for deadlock analysis. Args: thread_id: Thread ID. If omitted, shows current thread's locks.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread_id | string |
jdb_pop
Pop the current stack frame (discard it and return to caller). Allows re-executing the calling code with potentially modified state.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_reenter
Re-enter the current method from the beginning. Like pop, but re-executes the current method.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_redefine
Replace a loaded class's bytecode with a recompiled .class file (HotSwap), applying a fix to the running JVM without restarting it. The JVM only accepts changes to method bodies: adding or removing methods or fields, changing signatures, or changing the class hierarchy is rejected. New invocations run the new code; methods already on a thread's stack keep running the old code until they return (use jdb_reenter to restart the current method with the new code). The JVM deletes all breakpoints in a redefined class. This tool sets them again afterwards with their…
| Parameter | Type | Description |
|---|---|---|
class_file * | string | |
class_id * | string | |
port | integer |
jdb_trace
Trace method entries and exits. Args: what: What to trace: "methods" (entries+exits), "method exit" or "method exits". Prefix with "go" to not suspend (e.g. "go methods"). thread: Optional thread ID to restrict tracing to.
| Parameter | Type | Description |
|---|---|---|
port | integer | |
thread | string | |
what | string |
jdb_untrace
Stop tracing method entries and exits.
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_monitor
Set a command to execute automatically each time the program stops (at breakpoints, after steps, etc.). Useful for auto-printing variables. Args: command: JDB command to execute on each stop (e.g. "locals", "where", "print myVar").
| Parameter | Type | Description |
|---|---|---|
command * | string | |
port | integer |
jdb_monitor_list
List all active monitors (commands that auto-execute on stop).
| Parameter | Type | Description |
|---|---|---|
port | integer |
jdb_unmonitor
Remove a monitor by its number (from jdb_monitor_list). Args: monitor_number: The monitor number to remove.
| Parameter | Type | Description |
|---|---|---|
monitor_number * | integer | |
port | integer |
jdb_exclude
Set or display the step exclusion filter. Excluded classes are skipped when stepping. Default excludes java.*, javax.*, sun.*, com.sun.*, jdk.*. Args: class_patterns: List of class patterns to exclude (e.g. ["java.*", "javax.*"]). Use ["none"] to clear the filter. Omit to display current filter.
| Parameter | Type | Description |
|---|---|---|
class_patterns | array | |
port | integer |