karellen-jdb-mcp

v0.1.2
karellen-jdb-mcp Checked 3 days ago Published 1 month ago

MCP 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…

ParameterTypeDescription
classpathstring
hoststring
jdb_pathstring
portinteger
sourcepathstring
trackallthreadsboolean
wait_timeoutinteger

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.

ParameterTypeDescription
portinteger

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.

ParameterTypeDescription
portinteger

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.…

ParameterTypeDescription
command *array
envobject
working_directorystring

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.

ParameterTypeDescription
port *integer

jdb_launch_stop

Stop a launched JVM process. Args: port: The port returned by jdb_launch.

ParameterTypeDescription
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.

ParameterTypeDescription
argsstring
class_namestring
portinteger

jdb_cont

Continue execution until the next breakpoint, exception, or program exit.

ParameterTypeDescription
portinteger

jdb_step

Step into: execute current line, stepping into method calls.

ParameterTypeDescription
portinteger

jdb_next

Step over: execute current line, stepping over method calls.

ParameterTypeDescription
portinteger

jdb_step_up

Step out: execute until the current method returns to its caller.

ParameterTypeDescription
portinteger

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.

ParameterTypeDescription
portinteger
timeoutinteger

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.

ParameterTypeDescription
location *string
portinteger
suspend_policystring
thread_idstring

jdb_breakpoint_clear

Clear a breakpoint at a class:line or class.method location. Args: location: Same format as jdb_breakpoint_set.

ParameterTypeDescription
location *string
portinteger

jdb_breakpoint_list

List all currently set breakpoints.

ParameterTypeDescription
portinteger

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).

ParameterTypeDescription
class_pattern *string
filter_typestring
portinteger

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).

ParameterTypeDescription
class_pattern *string
filter_typestring
portinteger

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).

ParameterTypeDescription
class_field *string
access_typestring
portinteger

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.

ParameterTypeDescription
class_field *string
access_typestring
portinteger

jdb_threads

List all threads, grouped by thread group. Args: thread_group: Show only threads in this group. If omitted, shows all.

ParameterTypeDescription
portinteger
thread_groupstring

jdb_thread

Set the default thread for subsequent commands. Args: thread_id: Thread ID (from jdb_threads output, e.g. "0x1a8" or a number).

ParameterTypeDescription
thread_id *string
portinteger

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.

ParameterTypeDescription
portinteger
thread_idsarray

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.

ParameterTypeDescription
portinteger
thread_idsarray

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.

ParameterTypeDescription
portinteger
thread_idstring

jdb_up

Move up the call stack (toward the caller). Args: count: Number of frames to move up (default: 1).

ParameterTypeDescription
countinteger
portinteger

jdb_down

Move down the call stack (toward the callee). Args: count: Number of frames to move down (default: 1).

ParameterTypeDescription
countinteger
portinteger

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").

ParameterTypeDescription
expression *string
portinteger

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.

ParameterTypeDescription
expression *string
portinteger

jdb_eval

Evaluate a Java expression (alias for jdb_print). Args: expression: Java expression to evaluate.

ParameterTypeDescription
expression *string
portinteger

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()").

ParameterTypeDescription
expression *string
lvalue *string
portinteger

jdb_locals

List all local variables and their values in the current stack frame.

ParameterTypeDescription
portinteger

jdb_classes

List all currently loaded classes in the JVM.

ParameterTypeDescription
portinteger

jdb_class_info

Show details of a class (superclass, interfaces, etc.). Args: class_id: Fully qualified class name (e.g. "com.example.MyClass").

ParameterTypeDescription
class_id *string
portinteger

jdb_methods

List all methods of a class. Args: class_id: Fully qualified class name.

ParameterTypeDescription
class_id *string
portinteger

jdb_fields

List all fields of a class. Args: class_id: Fully qualified class name.

ParameterTypeDescription
class_id *string
portinteger

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.

ParameterTypeDescription
locationstring
portinteger

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.

ParameterTypeDescription
pathstring
portinteger

jdb_classpath

Print the classpath information from the target JVM.

ParameterTypeDescription
portinteger

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.

ParameterTypeDescription
expression *string
portinteger

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.

ParameterTypeDescription
portinteger
thread_idstring

jdb_pop

Pop the current stack frame (discard it and return to caller). Allows re-executing the calling code with potentially modified state.

ParameterTypeDescription
portinteger

jdb_reenter

Re-enter the current method from the beginning. Like pop, but re-executes the current method.

ParameterTypeDescription
portinteger

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…

ParameterTypeDescription
class_file *string
class_id *string
portinteger

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.

ParameterTypeDescription
portinteger
threadstring
whatstring

jdb_untrace

Stop tracing method entries and exits.

ParameterTypeDescription
portinteger

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").

ParameterTypeDescription
command *string
portinteger

jdb_monitor_list

List all active monitors (commands that auto-execute on stop).

ParameterTypeDescription
portinteger

jdb_unmonitor

Remove a monitor by its number (from jdb_monitor_list). Args: monitor_number: The monitor number to remove.

ParameterTypeDescription
monitor_number *integer
portinteger

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.

ParameterTypeDescription
class_patternsarray
portinteger