Sponsored by Deepsite.site

Jdwp Mcp

Created By
dronsva month ago
Debug live JVMs through JDWP — attach, breakpoints, inspect stacks/objects, evaluate methods. 25 tools for autonomous Java debugging.
Content

jdwp-mcp

Java debugging for LLMs via JDWP and Model Context Protocol

An MCP server that enables Claude Code and other LLM tools to debug Java applications through the Java Debug Wire Protocol (JDWP). Attach to running JVMs, set breakpoints, inspect variables, and step through code—all through natural language.

Features

  • Remote Debugging: Connect to any JVM started with JDWP enabled
  • Breakpoint Management: Set, list, and clear breakpoints by class and line
  • Stack Inspection: Get summarized stack frames with local variables
  • Execution Control: Step over/into/out, continue, pause
  • Expression Evaluation: Evaluate Java expressions in frame context
  • Thread Management: List and control thread execution
  • Smart Summarization: Handles large data structures without overwhelming the LLM

Quick Start

1. Start your Java app with JDWP enabled

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

2. Build the MCP server

cargo build --release

3. Configure Claude Code

The easiest way to enable the MCP server for your project:

# From your Java project directory
claude mcp add --scope project jdwp /path/to/jdwp-mcp/target/release/jdwp-mcp

Adjust the path to match where you cloned this repository. The --scope project flag makes the debugger available only in your current Java project.

Alternative: Manual configuration via .mcp.json:

{
  "mcpServers": {
    "jdwp": {
      "command": "/path/to/jdwp-mcp/target/release/jdwp-mcp"
    }
  }
}

4. Debug with natural language

> Attach to the JVM at localhost:5005
> Set a breakpoint at com.example.HelloController line 65
> When it hits, show me the stack and the value of requestCount

Available Tools

ToolDescription
debug.attachConnect to JVM via JDWP
debug.set_breakpointSet breakpoint at class:line
debug.list_breakpointsList active breakpoints
debug.clear_breakpointRemove a breakpoint
debug.continueResume execution
debug.step_overStep over current line
debug.step_intoStep into method
debug.step_outStep out of method
debug.get_stackGet stack frames with variables
debug.evaluateEvaluate expression
debug.list_threadsList all threads
debug.pausePause execution
debug.disconnectEnd debug session

Example: Debugging with kubectl port-forward

For Kubernetes-deployed Java apps:

# Forward JDWP port from pod
kubectl port-forward pod/my-app-pod 5005:5005

Then in Claude Code:

> Attach to localhost:5005
> Set a breakpoint in the processRequest method

Architecture

Claude Code → MCP Server → JDWP Client → TCP Socket → JVM
         Summarization &
         Context Filtering

The MCP server handles:

  • Protocol Translation: MCP JSON-RPC ↔ JDWP binary protocol
  • Smart Summarization: Truncates large objects, limits depth
  • State Management: Tracks breakpoints, threads, sessions

Development

Project Structure

jdwp-mcp/
├── jdwp-client/        # JDWP protocol implementation
│   ├── connection.rs   # TCP + handshake
│   ├── protocol.rs     # Packet encoding/decoding
│   ├── commands.rs     # JDWP command constants
│   ├── types.rs        # JDWP type definitions
│   └── events.rs       # Event handling
├── mcp-server/         # MCP server
│   ├── main.rs         # Stdio transport
│   ├── protocol.rs     # MCP JSON-RPC
│   ├── handlers.rs     # Request routing
│   ├── tools.rs        # Tool definitions
│   └── session.rs      # Debug session state
└── examples/           # Usage examples

Testing

Use the companion java-example-for-k8s as a test target:

cd ../java-example-for-k8s
mvn clean package
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 \
  -jar target/probe-demo-0.0.1-SNAPSHOT.jar

Then test MCP tools against this running app.

Building

# Debug build
cargo build

# Release build
cargo build --release

# Run tests
cargo test

Status

Core Functionality Complete - Ready for MCP integration

Implemented Features

  • Project structure
  • JDWP protocol (handshake, packets, encoding/decoding)
  • MCP server skeleton with 13 debug tools
  • VirtualMachine commands (Version, IDSizes, AllThreads, Suspend/Resume)
  • ClassesBySignature (find classes by name)
  • ReferenceType.Methods (get method info)
  • Method.LineTable (map source lines to bytecode)
  • Method.VariableTable (get variable metadata)
  • EventRequest.Set (breakpoints with location modifiers)
  • ThreadReference.Frames (get call stacks)
  • StackFrame.GetValues (read variable values)
  • Value formatting and display
  • Architecture independence (big-endian protocol, works on Intel & ARM M1/M2/M3)

Working Examples

  • test_connection - Basic JDWP handshake
  • test_vm_commands - Query JVM version and ID sizes
  • test_find_class - Find classes and methods with line tables
  • test_breakpoint - Set breakpoints at specific source lines
  • test_manual_stack - Suspend and inspect thread stacks with variables

Next Steps

  • Event loop for async breakpoint notifications
  • Stepping commands (step over/into/out)
  • Expression evaluation
  • String and object dereferencing
  • Full MCP server integration

References

License

MIT

Server Config

{
  "mcpServers": {
    "jdwp": {
      "command": "jdwp-mcp",
      "args": []
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
CursorThe AI Code Editor
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
WindsurfThe new purpose-built IDE to harness magic
Tavily Mcp
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
ChatWiseThe second fastest AI chatbot™
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
DeepChatYour AI Partner on Desktop
Playwright McpPlaywright MCP server