Skip to main content

Debug live JVMs through JDWP — from any MCP-compatible agent

Project description

jdwp-mcp

Debug live JVMs through JDWP — from any MCP-compatible agent.

License: MIT

Attach to a running Java process, pause threads, inspect stacks and objects, set breakpoints, and evaluate state — through natural language. Works with Claude Code, Codex, Cursor, or any MCP-compatible agent.

See it in action

A database query is hanging. Find the root cause:

> Attach to localhost:5005 and find out why a query is stuck.

The agent attaches, pauses all threads, and scans for the problem:

connected localhost:5005
paused
24 threads, 2 blocked

Thread pool-3-thread-7 is waiting for a monitor lock:
#0 RolapResult.loadMembers:142
  monitor=@3f2a  state=BLOCKED
#1 RolapResult.execute:89

Lock is held by pool-3-thread-2, which is running:
#0 SqlStatement.execute:218
  sql="SELECT ... FROM fact_table"   -- full scan on 36M rows

Root cause: the query bypassed the aggregate table and fell back to
a full fact-table scan. Thread-7 is waiting for thread-2 to finish.

One prompt. Six tool calls. Lock contention + root cause identified.

Quick Start

1. Install

curl -fsSL https://raw.githubusercontent.com/dronsv/jdwp-mcp/main/install.sh | sh
Other install methods
# pip (no Rust required)
pip install jdwp-mcp

# cargo
cargo install --git https://github.com/dronsv/jdwp-mcp

# from source
git clone https://github.com/dronsv/jdwp-mcp && cd jdwp-mcp && cargo build --release

2. Configure your agent

# If installed via cargo install:
claude mcp add jdwp jdwp-mcp

# If built from source:
claude mcp add jdwp /path/to/jdwp-mcp/target/release/jdwp-mcp

Works with any MCP-compatible agent. For non-Claude agents, add to .mcp.json:

{
  "mcpServers": {
    "jdwp": {
      "command": "jdwp-mcp"
    }
  }
}

3. Start your Java app with JDWP

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar app.jar

4. Debug

Attach to localhost:5005 and set a breakpoint at com.example.MyService line 42

First prompts

Copy-paste these to get started:

Attach to localhost:5005
List all threads and show which are blocked
Set a breakpoint at com.example.MyController line 65
When the breakpoint hits, show the stack and all variables
Pause the JVM and find threads waiting on locks

Why this instead of jstack or an IDE?

  • Works inside your agent — no tool switching, no separate debugger window
  • Combines attach + inspect + reasoning in one loop — the agent decides what to look at next
  • Conversational — describe the problem, the agent runs the debug session
  • Ground truth for large codebases — in complex projects with deep framework stacks (Spring, Hibernate, OLAP engines), agents can get lost tracing code paths statically. Live debugging gives the agent actual runtime state instead of guesses — which thread holds the lock, what SQL was generated, what value a variable actually has right now

Tools

25 tools organized in three groups:

Connection and control attach disconnect pause continue step_into step_over step_out

Breakpoints and events set_breakpoint (with optional conditions) clear_breakpoint list_breakpoints exception_breakpoint watch (field modification) wait_for_event get_last_event

Inspection and mutation get_stack (auto-resolves objects) get_variable inspect eval set_value snapshot find_class list_methods list_threads select_thread vm_info

Use it for

  • Hung requests and deadlocks
  • Blocked thread pools
  • Breakpoint-driven diagnosis in running services
  • State inspection when reproducing locally is hard
  • Remote debugging via kubectl port-forward

Don't use it for

  • Postmortem heap analysis
  • Always-on production observability
  • Environments where JDWP attach or thread pausing is operationally unsafe

Deploy scenarios

See docs/deploy.md for setup with Maven, Gradle, Tomcat, Docker, Kubernetes (port-forward), and SSH tunnels.

Operational note

JDWP changes runtime behavior. Pausing threads and setting breakpoints may be disruptive. Use carefully in production; prefer staging environments or controlled maintenance windows.

Examples

Architecture

Agent  -->  MCP Server  -->  JDWP Client  -->  TCP  -->  JVM
              |
        Translates tool calls to JDWP,
        tracks session state, summarizes
        runtime objects for the agent.

Core crates: jdwp-client (JDWP protocol) and mcp-server (MCP transport and session management).

Building from source

cargo build --release
cargo test

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jdwp_mcp-0.2.2.tar.gz (64.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jdwp_mcp-0.2.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file jdwp_mcp-0.2.2.tar.gz.

File metadata

  • Download URL: jdwp_mcp-0.2.2.tar.gz
  • Upload date:
  • Size: 64.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jdwp_mcp-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6d093421f4c9f24a871d3dbf7a49cce9124b556655816ac14dc8a2cd7eb90b3b
MD5 4f46966b5e4cd4deb35ed56aedc89d4d
BLAKE2b-256 11058fa3ffaab49c28b5c1c7ca62ebfd8c0674ac0c78c2892fa837ab5ecaf6e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for jdwp_mcp-0.2.2.tar.gz:

Publisher: release.yml on dronsv/jdwp-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jdwp_mcp-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: jdwp_mcp-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jdwp_mcp-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c400a8f1de2a4d83d7d8f350aa9f6c84d1b450e05a7b88a35f090600b0bfb23
MD5 d67d995067b8faf6dfe36bf99af8ef48
BLAKE2b-256 323059e17fddeb2156b646a67b0c605e96c4f9600b5a48b5c5f447a575a98edd

See more details on using hashes here.

Provenance

The following attestation bundles were made for jdwp_mcp-0.2.2-py3-none-any.whl:

Publisher: release.yml on dronsv/jdwp-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page