karellen-jdb-mcp

karellen-jdb-mcp

Enables LLMs to debug Java applications using JDB, supporting breakpoints, stepping, expression evaluation, thread analysis, and more.

Category
访问服务器

README

MCP Server for JDB Java Debugging (karellen-jdb-mcp)

Gitter Build Status Coverage Status

karellen-jdb-mcp Version karellen-jdb-mcp Python Versions karellen-jdb-mcp Downloads Per Day karellen-jdb-mcp Downloads Per Week karellen-jdb-mcp Downloads Per Month

Overview

karellen-jdb-mcp is an MCP (Model Context Protocol) server that enables any MCP-compliant LLM client to use JDB (the Java Debugger) for debugging JVM processes. The LLM can attach to a running JVM, set breakpoints, step through code, evaluate expressions, inspect threads, and analyze concurrency issues, all through structured JSON tool calls over the JDWP protocol.

Requirements

  • Java Development Kit (JDK) with jdb on PATH (JDK 8 through 24+ supported)
  • Python >= 3.10
  • Works on Linux, macOS, and Windows (anywhere JDB runs)

Installing a JDK

Fedora / RHEL / CentOS:

sudo dnf install java-21-openjdk-devel

Ubuntu / Debian:

sudo apt install openjdk-21-jdk

macOS (Homebrew):

brew install openjdk@21

Verify the setup

jdb -version

This should print something like This is jdb version 21.0.4.

Installation

pip install karellen-jdb-mcp

Or with pipx for an isolated environment:

pipx install karellen-jdb-mcp

Claude Code Integration

Claude Code plugin (recommended)

The plugin automatically configures the MCP server and includes:

  • Exception detection hook that suggests JDB when a Bash command output contains Java exception stack traces (Exception in thread, NullPointerException, etc.)
  • /karellen-jdb-mcp:jdb-debug skill that walks through the full launch-attach-debug workflow step by step, with build-tool-specific JDWP stanzas
  • jdb-investigator agent that Claude can spawn to autonomously investigate Java exceptions, deadlocks, and logic bugs using JDB

From the Karellen plugins marketplace:

claude plugin marketplace add karellen/claude-plugins
claude plugin install karellen-jdb-mcp@karellen-plugins

Or from the official Anthropic marketplace (if accepted):

claude plugin install karellen-jdb-mcp@claude-plugins-official

Or load directly from a local checkout for testing:

claude --plugin-dir /path/to/karellen-jdb-mcp

Manual MCP server configuration

If you prefer not to use the plugin, you can configure the MCP server directly. This gives you the MCP tools but not the skill, agent, or exception detection hook.

Using the CLI:

claude mcp add --transport stdio karellen-jdb-mcp -- karellen-jdb-mcp

Or manually add to ~/.claude.json (user scope) or .mcp.json in your project root (project scope, shared via version control):

{
  "mcpServers": {
    "karellen-jdb-mcp": {
      "type": "stdio",
      "command": "karellen-jdb-mcp"
    }
  }
}

If installed with pipx:

claude mcp add --transport stdio karellen-jdb-mcp -- pipx run karellen-jdb-mcp

or manually:

{
  "mcpServers": {
    "karellen-jdb-mcp": {
      "type": "stdio",
      "command": "pipx",
      "args": ["run", "karellen-jdb-mcp"]
    }
  }
}

Auto-approve jdb tools

By default Claude Code will prompt for confirmation before each jdb_* tool call. You can approve individually by selecting "Yes, and don't ask again" when prompted.

To auto-approve all tools upfront, add a permission rule to your user settings (~/.claude/settings.json):

{
  "permissions": {
    "allow": [
      "mcp__plugin_karellen-jdb-mcp_karellen-jdb-mcp__*",
      "mcp__karellen-jdb-mcp__*"
    ]
  }
}

The first rule covers plugin-loaded tools, the second covers manual MCP configuration.

Or for a project-scoped setting, add the same rule to .claude/settings.json in your project root (this file can be committed to version control so all team members get it).

Quick Start

With jdb_launch (recommended)

Launch the JVM with ${JDB_PORT} substitution — a random free port is allocated:

jdb_launch(["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:${JDB_PORT}",
            "-cp", "target/classes", "com.example.Main"])

Connect (port auto-resolves when there's one launched process):

jdb_connect(wait_timeout=30)

Debug:

jdb_breakpoint_set("com.example.Main:42")
jdb_run()
jdb_where()
jdb_locals()

Clean up:

jdb_disconnect()
jdb_launch_stop(port=<port>)

With a manually started JVM

Start the JVM yourself with JDWP on a known port, then connect:

jdb_connect(port=5005, wait_timeout=30)

Available Tools

Process Launch

Tool Description
jdb_launch Launch a JVM with JDWP on a random port. ${JDB_PORT} is substituted in the command.
jdb_launch_list List all launched JVM processes with status.
jdb_launch_status Get status of a launched process by port.
jdb_launch_stop Stop a launched process by port.

Session Lifecycle

Tool Description
jdb_connect Attach to a running JVM via JDWP. Auto-resolves port from single launched process, or defaults to 5005.
jdb_disconnect Disconnect and clean up. Port optional if only one session active.
jdb_session_list List all active debug sessions with port, connection status, and JDK version.
jdb_version Get JDB version info and available features.

Execution Control

Tool Description
jdb_run Start execution of the application's main class. Returns immediately once execution resumes.
jdb_cont Continue execution. Returns immediately once the JVM resumes (fire-and-forget). Returns stop event if a breakpoint/exception is hit within TIMEOUT_RESUME.
jdb_step Step into (enter method calls). Returns stop event on completion or returns immediately if execution resumes.
jdb_next Step over (skip method calls). Same return behavior as step.
jdb_step_up Step out (run until current method returns). Same return behavior as step.
jdb_wait_for_event Wait for a stop event after jdb_cont/jdb_run returned reason="resumed". Blocks until breakpoint/exception/exit or timeout (default 120s).

Breakpoints

Tool Description
jdb_breakpoint_set Set breakpoint at class:line or class.method. Supports thread filters and suspend policy on JDK 13+.
jdb_breakpoint_clear Clear a breakpoint.
jdb_breakpoint_list List all breakpoints.
jdb_catch Break on exception (caught/uncaught/all). Supports wildcard patterns.
jdb_ignore Cancel an exception breakpoint.

Watchpoints

Tool Description
jdb_watch Watch field access/modifications.
jdb_unwatch Remove a field watchpoint.

Thread Management

Tool Description
jdb_threads List all threads by group with status.
jdb_thread Set default thread for subsequent commands.
jdb_suspend Suspend threads (all or specific).
jdb_resume Resume threads (all or specific).

Stack Navigation

Tool Description
jdb_where Get call stack (stack trace). Use "all" for all threads.
jdb_up Move up the call stack (toward caller).
jdb_down Move down the call stack (toward callee).

State Inspection

Tool Description
jdb_print Evaluate Java expression (fields, locals, method calls, arithmetic).
jdb_dump Dump object showing all fields (static and instance).
jdb_eval Evaluate expression (alias for print).
jdb_set Assign value to variable, field, or array element.
jdb_locals List local variables with values.

Class Introspection

Tool Description
jdb_classes List all loaded classes.
jdb_class_info Show class details (superclass, interfaces).
jdb_methods List class methods.
jdb_fields List class fields.

Source

Tool Description
jdb_list List source code at current position or specified location.
jdb_sourcepath Display or change source path for .java files.
jdb_classpath Print classpath info from target JVM.

Concurrency Analysis

Tool Description
jdb_lock Object lock/monitor info (owner thread, waiting threads).
jdb_threadlocks Thread lock info (owned monitors, lock being waited on).

Frame Manipulation

Tool Description
jdb_pop Pop current frame (return to caller, allows re-execution).
jdb_reenter Re-enter current method from the beginning.

Tracing

Tool Description
jdb_trace Trace method entries/exits (optionally per-thread).
jdb_untrace Stop tracing.

Monitors (Auto-execute)

Tool Description
jdb_monitor Auto-execute a command on every stop (e.g. "locals", "where").
jdb_monitor_list List active monitors.
jdb_unmonitor Remove a monitor.

Configuration

Tool Description
jdb_exclude Set/display step exclusion filter (skip library classes when stepping).

Note: All debugging tools accept an optional port parameter. When only one session is active, it auto-resolves. When multiple sessions are active, port is required.

Configuration

Timeouts

All timeouts are configurable via environment variables (in seconds). Set them in your MCP server configuration:

{
  "mcpServers": {
    "karellen-jdb-mcp": {
      "type": "stdio",
      "command": "karellen-jdb-mcp",
      "env": {
        "JDB_MCP_TIMEOUT_EXECUTION": "300"
      }
    }
  }
}
Variable Default Description
JDB_MCP_TIMEOUT_CONNECT 60 JDB attach and initial prompt
JDB_MCP_TIMEOUT_COMMAND 30 Non-execution commands (breakpoints, inspection, etc.)
JDB_MCP_TIMEOUT_EXECUTION 120 Prompt-based commands (used internally by send_command)
JDB_MCP_TIMEOUT_RESUME 5 Execution commands (run, cont, step, next, step up). These return immediately when output arrives or after this timeout if execution resumes with no output (fire-and-forget).

Build Tool Debug Stanzas

To debug a JVM process, it must be started with the JDWP agent. The exact syntax varies by build tool:

Build Tool Command
Plain java java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005 ...
Maven Surefire mvn -Dmaven.surefire.debug test
Maven Failsafe mvn -Dmaven.failsafe.debug verify
Gradle tests ./gradlew test --debug-jvm
Tycho Surefire mvn verify -Dtycho.testArgLine="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
Spring Boot mvn spring-boot:run -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
Any (fallback) JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005" <command>

License

Apache-2.0

Privacy

See PRIVACY.md. This software does not collect or transmit any data.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选