Not loaded · from java-agent-debugger
Drives the JDK's jdb debugger as a stateful MCP session to inspect runtime state: variable values, exception causes, thread locks/deadlocks, and step-through execution. Attaches to running JVMs with JDWP.
Claude Code won't load this skill
It ships in java-agent-debugger at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
jdbg is an MCP server that drives the JDK's jdb debugger as a stateful background session, so you
can debug a Java program across many separate tool calls. Each tool call (launch, break_at, run,
locals, …) sends ONE command to the session and returns a structured result. A background daemon keeps
the JVM and debugger state alive between calls — set a breakpoint in one call, run in the next, inspect in the
next.
The tools appear as
mcp__jdbg__<tool>(e.g.mcp__jdbg__break_at). Below they are named bare (break_at) for brevity. The first tool call auto-starts the background daemon — no setup step is needed.
Core loop: react to each result. Call one tool, read its structured output, then decide the next call.
Do NOT batch commands or tune timing — jdbg waits for jdb to be ready (no sleeps), and a hung program
returns a non-destructive Timeout, not a freeze.
When NOT: logic simple enough to read; a compile/build error (that is javac, not a debugger); no
running JVM and nothing launchable.
Launch a program under the debugger (you have the main class + classpath) — call launch with
main_class (and usually classpath; pass program args via app_args):
launch { "main_class": "com.example.Main", "classpath": "out", "sourcepath": "src", "app_args": ["arg1", "arg2"] }
Returns a session id, state loaded (JVM not started yet). Set breakpoints, then call run.
Attach to a running JVM started with JDWP — call attach:
attach { "host": "localhost", "port": 5005, "sourcepath": "src" }
The default JDI backend returns state running for attach; set breakpoints, then call cont (attach has no
run). If local JDI prerequisites are missing, an omitted backend automatically falls back to jdb and
returns a note; explicit backend: "jdi" means JDI is required and does not fall back.
If sourcepath is omitted, jdbg uses the MCP server's current working directory as the source root and sends it
to the daemon as an absolute path. On JDI sessions, source lookup also tries the target JVM's user.dir and
Maven/Gradle module roots inferred from java.class.path (for example mall-portal/target/classes →
mall-portal/src/main/java). Pass sourcepath explicitly when sources live outside the workspace root or
the target classpath does not reveal module directories.
localhostis auto-normalized to127.0.0.1. On dual-stack machineslocalhostoften resolves to IPv6[::1], but JDWP usually listens only on IPv40.0.0.0→ connection refused. jdbg rewriteslocalhostto the IPv4 loopback so attach just works; the responsetargetfield shows the address actually connected, plus anote. To force IPv6, passhost: "::1"explicitly.
Start the target JVM with:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=<ADDR>
address=5005 (all interfaces) or address=localhost:5005. *:5005 is NOT valid on JDK 8.address=*:5005 is allowed.suspend=y makes the JVM wait for the debugger; suspend=n attaches to an already-running app.launch { "main_class": "Main", "classpath": "out" } (or attach { "port": 5005 })break_at { "class": "com.example.Main", "line": 42 } — set a line breakpointrun (launch) or cont (attach) — execution stops at the breakpoint → Stoppedlocals, where, print { "expr": "..." }step / next / contcont to run to exit (VmExited) or killCommon arguments: any session tool accepts session (a session id; omit when exactly one session exists);
execution-control tools (run / cont / step / next / step_out) also accept timeout (seconds,
overrides the default). To force a specific JDK, pass jdb_path to launch / attach (jdb is otherwise
found via JAVA_HOME/bin → PATH → common install dirs). On JDI sessions, jdb_path also selects the sidecar
Java runtime when JDBG_JDI_JAVA is not set.
backend for the default JDI backend. If the sidecar jar is missing or JDK 8 tools.jar cannot be found, jdbg falls back to jdb and returns a note explaining why.backend: "jdi" when you require JDI and want local prerequisite failures to surface instead of falling back. JDI supports line and method breakpoints (including conditional breakpoints, evaluated server-side), exception catchpoints, watchpoints, run for launched sessions, cont, step/next/step_out, stack/frame navigation, class/method lookup, source listing, thread suspend/resume, locks, safe JSON inspect, executable print/eval/dump, set, and non-void force_return.backend: "jdb" when you need literal jdb stdin passthrough through raw (monitor, redefine, trace, and other jdb-only commands).loaded; set breakpoints, then call run. JDI attach starts in state running; set a line or method breakpoint, then call cont to wait for the next stop.jdb for conditional breakpoints (JDI supports them). The only things JDI does not do are literal jdb stdin passthrough via raw (JDI raw only dispatches known jdb-style aliases) and void force_return. Use a jdb session only when you need one of those.jdbg-jdi-sidecar.jar next to the jdbg binary. Release updates install the official jar there; source builds create it during cargo build. If the jar is missing, run jdbg update or reinstall from the official release archive. Do not search the filesystem and copy a jar from a source checkout. Override with JDBG_JDI_SIDECAR_JAR or JDBG_JDI_JAVA only when necessary.| Tool | Purpose |
|---|---|
launch { main_class, backend?, classpath?, sourcepath?, app_args?, jdb_args?, name?, jdb_path? } | start a JVM under the selected backend (state loaded); jdb_args is jdb-only |
attach { backend?, host?, port?, sourcepath?, name?, jdb_path? } | attach to a running JVM via JDWP; pass backend: "jdi" for the JDI sidecar |
status · list | current state / all sessions |
kill | end the session (defaults to the sole session; pass session if more than one) |
For JDI sessions, status changes as soon as a stop event reaches the sidecar. pending_stops > 0 means a
stop is waiting for an execution-control command to consume it, rather than an idle VM that is still running.
With several thread-suspended hits, last_event and inspection commands refer to the current stop, while
pending_stops counts that stop and the queued stops.
Calling resume without an id discards all pending JDI stops and clears last_event when intentionally
continuing past an asynchronous hit.
Daemon management is automatic: the daemon starts on the first tool call and persists. There is no MCP tool to start/stop it — it is an implementation detail, not part of the debugging surface.
| Tool | Purpose |
|---|---|
break_at { class, line, condition?, suspend? } | break at a source line |
break_in { class, method, event?, args?, condition?, suspend? } | break at method entry by default; JDI also supports event: "exit" and "both" |
catch { exception, mode? } | break when an exception is thrown (mode: caught | uncaught | all) |
watch { field, mode? } | break when a field is accessed or modified (mode: access | modification | all; default: modification) |
unwatch { field, mode? } | remove field watchpoint(s) (mode: access | modification | all; default: modification) |
breakpoints · clear { spec } | list / remove breakpoints |
Conditional breakpoints — filter for a specific request in high-traffic code:
break_at { "class": "com.example.CartService", "line": 42, "condition": "userId == 1619458289" }
The condition is evaluated each time the breakpoint fires; execution automatically continues if false.
Backend differences: the JDI backend evaluates the condition server-side in the sidecar, so cont/run/step
only stop when it holds (a bad or non-boolean condition stops with a note). For the jdb backend on an
already-running attached JVM, if the breakpoint fires before your next blocking command, the next
inspection command (threads, where, print, locals, etc.) first resolves any false conditional hit and
continues automatically.
Thread breakpoints (suspend: "thread") — like IDEA's "Suspend: Thread" option. Only the hit thread
is suspended; all other threads (ZooKeeper heartbeat, Dubbo registry, other HTTP handlers) keep running.
Use this when debugging a live server to prevent the service from being deregistered:
break_at { "class": "com.example.CartService", "line": 42, "suspend": "thread" }
The Stopped response will include a note confirming thread-level suspend is active. All inspection
commands (locals, print, where) work normally on the suspended thread. When you cont, the next
breakpoint hit re-applies the same policy automatically.
You can combine both: { "condition": "userId == 123", "suspend": "thread" } — only stop for the
target user, and only freeze that one request thread when it does stop.
| Tool | Purpose |
|---|---|
run | start the app (launch mode only) |
cont | continue until the next stop |
step · next · step_out | step into · over · out of the current method |
JDI step/next/step_out remain on the currently stopped thread. Concurrent events from unrelated threads
are resumed while the step is active and cannot replace its result.
These tools return a Stopped result that automatically includes source context (surrounding source
lines with => marking the current line), the top stack frame, and the hit thread's id
(thread_id) when available. You do NOT need to call list_source or where separately after stopping —
the information is already in the response. To switch to or act on the hit thread, pass thread_id
straight to thread/suspend/threadlocks — no need to scan threads for it.
| Tool | Purpose |
|---|---|
locals | local variables in the current frame |
print { expr } · eval { expr } | value of an expression (JDI may call methods on live objects) |
dump { expr } | all fields of an object |
inspect { expr, max_elements? } | show size + first N elements of a collection/array (default 10, max 50) |
where { all? } | call stack of the current thread (or every thread with all: true) |
threads { filter? } · thread { id } | list threads (filter by name substring) / switch the current thread |
frame { direction, n? } | move within the call stack (direction: up | down) |
list_source { line? } | show source around a line |
classes { pattern? } | search loaded classes by substring — find CGLIB proxies, inner classes, or confirm a class is loaded |
methods { class } | list all methods of a loaded class (with param types) — find exact signature for break_in |
raw { command } | escape hatch: on JDI, dispatch supported aliases only; use backend: "jdb" for literal jdb commands (monitor, redefine, trace, …) |
| Tool | Purpose |
|---|---|
suspend { id? } · resume { id? } | suspend/resume one thread (or all if no id) — fine-grained control without freezing the whole VM |
set { lvalue, value } | assign a variable/field/array element — mutates live state to test a fix or force a branch |
force_return { value } | JDI only: force the current non-void method to return a value expression — mutates control flow |
ignore { exception, mode? } | stop catching an exception (removes a catch); mode must match how it was caught |
lock { expr } | monitor owner + waiters for an object — contention/deadlock diagnosis |
threadlocks { id? } | locks a thread holds and is blocked on — the core deadlock command |
Every tool returns a typed result. The ones that drive the next move:
Stopped — a breakpoint or step landed. The response already includes source context (lines around
the stop with => marking the current line), the top stack frame, and the hit thread's thread_id — you can
read them immediately without extra calls. Execution stops before the indicated line runs (the line has
not yet executed). Use locals / print { expr } / inspect { expr } to examine state. To act on the hit
thread (switch, suspend, inspect its locks), pass thread_id directly — do not scan threads for it.
For JDI method events, event.type is method_entry or method_exit; method exit includes the return
value when available.ExceptionCaught — an exception fired. where for the throw site, locals for state.VmExited — the program ended; the session is done (list / kill).Timeout — the app did not stop within the timeout (long loop or deadlock). The session is kept
alive and marked running — investigate with threads / where { all: true }, or kill. Re-run the
blocking tool with a larger timeout if it just needs more time.[note] about line mismatch means the JVM rounded the breakpoint to the nearest line with executable
bytecode — this is normal for lines that are comments, blank, or declarations-only.[note] about -g means the class lacks local-variable debug info → recompile with javac -g.sourcepath (e.g. a framework class like Tomcat's
CoyoteAdapter) attaches two benign WARNING: lines — failed to enrich JDI source context: … source_not_found
and could not retrieve JDI source context (is sourcepath set…). These are noise, not failures: the stop,
locals, print, eval, and inspect all still work. Add the framework's sources to sourcepath if you want
the source snippet; otherwise ignore them.Use inspect instead of manually looping print expr.get(0), print expr.get(1), etc.:
inspect { "expr": "myList" } → shows size + all elements (up to 10)
inspect { "expr": "myMap", "max_elements": 20 } → first 20 entries (inspect the map itself, not map.keySet())
On JDI sessions, safe JSON inspect reads fields directly and does not invoke getters; it covers common
ArrayList, LinkedList, ArrayDeque, HashSet, LinkedHashSet, TreeMap, TreeSet, HashMap,
LinkedHashMap, unmodifiable wrappers, arrays, and ordinary objects. It resolves locals, this, instance and
static fields, field chains, and array access, but rejects method calls (e.g. map.keySet(),
System.getProperties()) with a method_invocation_not_allowed error pointing you to print/eval. On jdb
sessions, inspect keeps the classic collection/array summary behavior. Results include size/entries/elements
and truncation metadata where available.
On JDI sessions, print, eval, dump, set, and force_return are executable capabilities. They may
invoke methods in the target JVM and can have side effects. Use print/eval for anything with a method call
(obj.getX(), System.getProperties()); use inspect when you need safe field-reading without getters.
An executable evaluation can block in target code. If it times out, do not retry it: evaluation_in_progress
means the first call is still running. The session control path stays available, so use threads, clear,
resume, or kill to recover. JDI cannot cancel the original method call. Executable evaluation requires a
breakpoint/step/exception stop; manually suspending a thread is not an evaluation site. Set a breakpoint in the
target method and wait for Stopped instead.
After JDI force_return, the target VM applies the forced return when the thread resumes. A where call before
the next cont/step may still show the old frame and include a note explaining that pending refresh.
Use classes to discover runtime class names — essential when Spring wraps beans in CGLIB proxies:
classes { "pattern": "CartService" }
→ ["com.example.CartService", "com.example.CartService$$EnhancerBySpringCGLIB$$a1b2c3"]
Then use methods to find the exact method signature for break_in:
methods { "class": "com.example.CartService" }
→ ["void addItem(java.lang.String, int)", "java.util.List getItems()", ...]
Always pass a pattern to classes — without one it returns ALL loaded classes (thousands in a Tomcat JVM).
Use watch to find out who modifies a field and when:
watch { "field": "com.example.Config.timeout", "mode": "modification" }
cont
→ Stopped (FieldWatch): field modified at Config.setTimeout() line=42
Modes: modification (default, catch writes), access (catch reads), all (both).
watch with mode: "all" creates separate access and modification watchpoints. You can remove them
independently: unwatch { "field": "com.example.Config.timeout", "mode": "modification" } leaves the
access watchpoint active, and mode: "access" removes the read watchpoint. Use mode: "all" when you want
to remove both classes of watchpoint in one call.
Field watchpoints fire during blocking commands (run/cont/step/next/step_out) — the response
includes the location, thread, and enriched source context just like breakpoint hits.
On JDI sessions, watchpoints are supported through the same blocking execution controls.
locals empty / "information not available" → the class was compiled without debug info. Recompile
with javac -g.run after attach → attach has no run (the JVM is already running); use cont.}-only line has no code), or wrong class. Note that
breakpoints set before the class loads are deferred (this is normal) and bind on run/cont.list_source/where after every stop → unnecessary. Stopped results already include source
context and the top stack frame. Only call them if you need the full stack or a different line range.session (an id from list), or keep one session at a time.list to find the existing session id, then reuse it or kill it first before re-attaching.set string values → the value field is a Java expression. For string literals, pass the value
directly (e.g. "TestHeader") — the tool auto-quotes values that look like bare strings (contain hyphens,
slashes, etc.). For numbers, null, true/false, or variable references, pass them unquoted.jdb_path to launch / attach, or set JAVA_HOME, to force a specific
JDK (e.g. JDK 8 vs JDK 21).jdbg update or reinstall from the official release archive. Do not
globally search for jdbg-jdi-sidecar.jar or copy one from a source checkout; it may not match the installed
binary. When backend is omitted, jdbg falls back to jdb with a note; explicit backend: "jdi" reports
the error.attach/launch fails or times out on JDK 8 → the sidecar needs tools.jar
(JDK 8 ships JDI only there; JDK 9+ bundles it in the runtime). jdbg auto-discovers it via jdb_path,
JAVA_HOME, or PATH; if it cannot, set JDBG_JDI_TOOLS_JAR to <jdk8>/lib/tools.jar, or point JAVA_HOME
at a JDK 8 that has it.
JDK 9+ is unaffected. Omitted backend falls back to jdb; explicit backend: "jdi" reports the error.attach "connection refused" / "not reachable" on a port that IS listening → dual-stack address
mismatch: localhost resolves to IPv6 [::1] but JDWP listens on IPv4 0.0.0.0 (check netstat). jdbg
auto-normalizes localhost→127.0.0.1; if you passed some other hostname that still fails, retry with the
literal 127.0.0.1.Do NOT kill + re-attach to the same JVM repeatedly. jdb reconnection to the same JDWP port (without
restarting the JVM) is unreliable on JDK 8 — breakpoint event registration may silently fail on the second
connection, causing cont to timeout indefinitely.
Best practice: use a single session for the entire debugging task:
attach oncecont, inspect, step/next, cont again — all within the same sessionkill (this resumes the VM so the server keeps running)attach fresh — but avoid rapid kill+re-attach cyclesIf where / locals returns empty or "No thread specified" immediately after a Stopped result:
threads to see if the hit thread shows running (at breakpoint) (normal) or
cond. waiting (abnormal — session may need to be killed and re-attached)thread { id } tool can force-set the current thread by name (the thread name from the Stopped
event, e.g. http-nio-8080-exec-5)threads outputAfter a stop, prefer the thread_id field from the Stopped result — it is the hit thread's id, ready
to pass to thread/suspend/threadlocks. You only need the threads output below when targeting a
different thread than the one that stopped.
The threads output shows lines like 0x37bd http-nio-8231-exec-8 cond. waiting (the hit thread, if any, is
prefixed with *). Pass the id exactly as shown to the thread tool — copy it verbatim, do not reformat
it. Do NOT pass the thread name (e.g. http-nio-8231-exec-8) — jdb rejects names. On a large app, use
threads { "filter": "http-nio" } to cut the list down instead of scanning 90+ lines.
The id format depends on the JDK: most print a 0x-prefixed hex value (0x37f2), but some (commonly
external Tomcat / app-server attach) print a plain decimal value (18315). Use whichever the
threads output gave you, unchanged — do NOT add a 0x prefix to a decimal id, and do NOT strip the
0x from a hex id. Both forms are wrong if reformatted, and jdb will reject them.
Example: if threads shows 0x37f2 http-nio-8231-exec-20, use thread { "id": "0x37f2" }.
If it shows 18315 http-nio-9702-exec-1, use thread { "id": "18315" }.
Note: if the thread is no longer suspended (e.g. it has finished executing and returned to the pool),
thread will report "not a valid thread id" even with the correct id. This indicates the
breakpoint did not hold the thread — see the guidance above about retrying or re-attaching.
When attaching to an external Tomcat (or similar) started with JDWP:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
suspend=n is correct — it means Tomcat doesn't wait for the debugger at startupsuspend: "thread" on your breakpoints:
break_at { "class": "com.example.Handler", "line": 100, "suspend": "thread" }
This keeps the service registered in ZK/gateway while you inspect the hit thread.suspend: "thread", the server will freeze until you cont — inspect quicklykill resumes the VM before disconnecting so the server continues running afterwardsWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub pieceoffall/jdbg --plugin java-agent-debugger2 skills in this plugin
Other plugins' skills for the same job