Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ If your agent runs in a terminal, a pipeline, or a cloud sandbox — or needs to
- 🧪 **Mock adapter for testing** – Test without external dependencies
- 🛰️ **Out-of-IDE & remote attach** – Attach over host/port to a process on another machine or inside a container (Python via debugpy, Ruby via rdbg, JavaScript via the V8 inspector, Java via JDWP, Dart/Flutter via the VM-service URI) with source-path mapping, or by PID for native code (C/C++, COBOL) and for a local Node.js process (JavaScript), whose inspector mcp-debugger opens for you and, until [#1261](https://github.com/debugmcp/mcp-debugger/issues/1261) is fixed, leaves open after you detach. Python and Ruby attach *direct-connect* — the debug engine already runs inside the target, so no local Python or Ruby is needed; JavaScript, Java, .NET, C/C++, COBOL and Dart/Flutter spawn a local adapter instead; of those, only Java (a JDK), .NET (netcoredbg) and Dart/Flutter (the Dart or Flutter SDK, whose own debug adapter does the work) need a toolchain you install, since the JavaScript, C/C++ and COBOL debug engines ship with the package. `list_supported_languages` reports per-mode availability with reasons
- 🎯 **Breakpoints that survive edits** – Address by content (`statement: "total = sum(prices)"`), by symbol (`function: "main"`), or assert line content with `expectedContent`; anchors re-resolve across `restart_debugging` and weak matches warn loudly
- 🪵 **Logpoints** – `set_breakpoint` with `logMessage: "x={x}"` streams interpolated values into `get_output` without pausing the program. They are not free, and on a live service there are three costs to know first ([details and measurements](docs/tool-reference.md#logpoints)): **an attached debugger and, for Python, JavaScript and Dart, an open debug port** (a debugger stays attached for as long as you watch; a running Python, JavaScript or Dart process is reached through a debug port on it; and attaching to a Node.js process by PID opens its inspector, on `127.0.0.1:9229` by default, and leaves it listening, unauthenticated, after you detach: [#1261](https://github.com/debugmcp/mcp-debugger/issues/1261)); **time per hit** (about 25 µs in Python to about 5 ms in Dart); and **a slower function** (JavaScript and Dart de-optimize any function that holds a line breakpoint or a logpoint, and Python traces its every line, so the whole function runs slower while the logpoint is set: 1.7× in Dart, 2.6× in JavaScript and 58× in Python in the reference's table)
- 🪵 **Logpoints** – `set_breakpoint` with `logMessage: "x={x}"` streams interpolated values into `get_output` without pausing the program. They are not free, and on a live service there are three costs to know first ([details and measurements](docs/tool-reference.md#logpoints)): **an attached debugger and, for Python, JavaScript and Dart, an open debug port** (a debugger stays attached for as long as you watch; a running Python, JavaScript or Dart process is reached through a debug port on it; and attaching to a Node.js process by PID opens its inspector, on `127.0.0.1:9229` by default, and leaves it listening, unauthenticated, after you detach: [#1261](https://github.com/debugmcp/mcp-debugger/issues/1261)); **time per hit** (about 12 µs in Python to about 5 ms in Dart); and **a slower function** (JavaScript and Dart de-optimize any function that holds a line breakpoint or a logpoint, and Python traces its every line, so the whole function runs slower while the logpoint is set: 1.7× in Dart, 2.6× in JavaScript and 56× in Python in the reference's table)
- 🧰 **Full breakpoint lifecycle** – `list_breakpoints` / `remove_breakpoint` / `clear_breakpoints` work live mid-run; `restart_debugging` relaunches with the same config and re-applies everything in one call
- 📡 **Buffered program output** – `get_output` returns debuggee stdout/stderr with a cursor, and each session exposes its transcript as a subscribable MCP resource
- 💥 **Crash-state debugging by default** – Launch sessions pause on uncaught exceptions with stack and locals live (`breakOnExceptions`; exception class/message surfaced via `lastStop`)
Expand Down
2 changes: 1 addition & 1 deletion changelog.d/1261-logpoint-costs.fixed.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
**The docs state the three known costs of a logpoint** — the README still called logpoints "prod-safe value watching on hot paths". It now names three costs, and the tool reference explains each. A debugger stays attached for as long as you watch, which for a running Python, JavaScript or Dart process means an open debug port, and an attach to a Node.js process by PID leaves the inspector it opened (`127.0.0.1:9229` by default) listening, unauthenticated, after detach and close (#1261); the JavaScript guide, the debugging skill and the server's workflow prompt no longer present that only as a convenience. Each hit costs time. And in Python, JavaScript and Dart a function that holds a line breakpoint of any kind runs slower as a whole while it holds it: V8 and the Dart VM stop optimizing it, and debugpy traces its every line. Newly measured for JavaScript and Python, attached by port: the function is back at its time without the logpoint by the second recorded call after the logpoint is removed or the debugger detaches, and a hit cost about the same (JavaScript) or less (Python) than in launch mode (#1218, #1261)
**The docs state the three known costs of a logpoint** — the README still called logpoints "prod-safe value watching on hot paths". It now names three costs, and the tool reference explains each. A debugger stays attached for as long as you watch, which for a running Python, JavaScript or Dart process means an open debug port, and an attach to a Node.js process by PID leaves the inspector it opened (`127.0.0.1:9229` by default) listening, unauthenticated, after detach and close (#1261); the JavaScript guide, the debugging skill and the server's workflow prompt no longer present that only as a convenience. Each hit costs time. And in Python, JavaScript and Dart a function that holds a line breakpoint of any kind runs slower as a whole while it holds it: V8 and the Dart VM stop optimizing it, and debugpy traces its every line. Newly measured for JavaScript and Python, attached by port: the function is back at its time without the logpoint by the second recorded call after the logpoint is removed or the debugger detaches, and a hit cost about the same (JavaScript) or less (Python, measured while a launched Python program still ran with debugpy's debug log on: see #1264) than in launch mode (#1218, #1261)
1 change: 1 addition & 0 deletions changelog.d/1264.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**A launched Python program no longer runs with debugpy's debug log on** — the adapter started debugpy with `DEBUGPY_LOG_DIR` set to the session's log directory for every launch, and debugpy then turns its debug log on inside the debugged program as well: pydevd writes a line for every message it sends, on the program's own threads. Measured on one machine, that log was more than half the cost of a logpoint hit (26.1 µs with it, 11.7 µs without), and it made a freeze far more likely when two threads reach breakpoints together (#1384: 6 freezes in 600 rounds with the log on, none in 600 with it off). The adapter no longer sets the variable, and the policy's fallback spawn no longer passes `--log-dir`. To get debugpy's logs, set `DEBUGPY_LOG_DIR` in the server's environment: it passes through. Attach is unchanged: an attached program logs the way it was started. The docs and the `set_breakpoint` description carry the new figures (#1264, #1384)
5 changes: 3 additions & 2 deletions docs/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set_breakpoint { "sessionId": "...", "file": "/abs/path/script.py", "line": 15,
set_breakpoint { "sessionId": "...", "file": "/abs/path/script.py", "line": 15, "logMessage": "x={x} y={y}" }
```

A logpoint never pauses: it interpolates the `{expressions}` and writes the line to `get_output` while the program keeps running. Each hit does cost time, however — measured at 24.7 µs per hit on Python 3.13 + debugpy (`sys.monitoring`, 2.5% of a core at 1,000 hits/s), and placing a logpoint anywhere in a function slows that whole function by 58× — so keep logpoints off tight loops. When hits outrun debugpy's delivery rate (measured at 3,200–4,400 lines/s during a run and about 6,000 lines/s draining afterward), lines still queued when the program exits are lost and the session's end answer does not report the loss (issue #1265). See [Logpoints](../tool-reference.md#logpoints) for measurement conditions and what was not measured.
A logpoint never pauses: it interpolates the `{expressions}` and writes the line to `get_output` while the program keeps running. Each hit does cost time, however — measured at 11.7 µs per hit on Python 3.13 + debugpy (`sys.monitoring`, 1.2% of a core at 1,000 hits/s), and placing a logpoint anywhere in a function slows that whole function by 56× — so keep logpoints off tight loops. When hits outrun debugpy's delivery rate (a few thousand lines a second), lines still queued when the program exits are lost and the session's end answer does not report the loss (issue #1265). See [Logpoints](../tool-reference.md#logpoints) for measurement conditions and what was not measured.

#### What a logpoint message may contain

Expand Down Expand Up @@ -298,7 +298,7 @@ Variable values, captured output, and evaluate results are scanned for credentia

### Logpoint lines lost at program exit

When a Python logpoint fires faster than debugpy delivers messages (measured at 3,200–4,400 lines/s during a run and about 6,000 lines/s while draining after a loop), lines still queued in the debuggee when the program exits are dropped. The session's end answer reports a normal exit with no indication that lines were lost (issue #1265). See [Logpoints](../tool-reference.md#logpoints) for the full measurement.
When a Python logpoint fires faster than debugpy delivers messages (a few thousand lines a second), lines still queued in the debuggee when the program exits are dropped. The session's end answer reports a normal exit with no indication that lines were lost (issue #1265). See [Logpoints](../tool-reference.md#logpoints) for the full measurement.

### Steps lost during exception unwinding (Python 3.12+)

Expand All @@ -321,3 +321,4 @@ The launch passes `dapLaunchArgs.env` through the Python adapter to debugpy. mcp
4. The stack trace shows the call hierarchy that led to the current position
5. Expressions are evaluated against the current paused debug context (current frame when available), with the evaluation context defaulting to `'variables'` — reads and arithmetic are reliable, but verify a mutation such as `x = 5` with a follow-up evaluate before relying on it
6. Child processes are debug sessions by default: debugpy's sub-process debugging is on (the last step of [#1081](https://github.com/debugmcp/mcp-debugger/issues/1081)), so every Python child the program starts (`subprocess`, `multiprocessing`, pytest-xdist workers, an autoreloader, a script that shells out to Python) becomes a child debug session of its own: `list_debug_sessions` lists it with `parentSessionId` naming this session, it stops on the breakpoints set on this session before launch (re-sent to it before it runs), and it has its own `get_output` and `close_debug_session`; closing the parent closes its children first. A `wait_for_stop` on this session is a wait on the tree: it reports a child's stop with `sessionId` naming the child (inspect, step and continue with that id) and `children` listing every child session with its state; a child can still be waited on by its own id. Each child parks until it is adopted (about 110 ms from report to its first stop), is a session row, and counts against `DEBUG_MCP_MAX_CHILD_SESSIONS` (default 32 live children per tree; beyond it a child is released and runs undebugged). Opt out per launch with `dapLaunchArgs: { subProcess: false }` (the children run undebugged and the launch answer's warning says so), per attach target with `python -m debugpy --listen … --configure-subProcess false` (or `debugpy.configure(subProcess=False)` in code — the attach request's `subProcess` is inert), or server-wide with `DEBUG_MCP_MAX_CHILD_SESSIONS=0`. The design is [the session tree](../architecture/session-tree.md), built on the handshake measured in [spike-notes-subprocess.md](spike-notes-subprocess.md)
7. debugpy's own logs (`debugpy.*.log`) are off by default. To turn them on for launched sessions, set `DEBUGPY_LOG_DIR` to a directory in the server's environment (for an attach target, pass `--log-to <dir>` or set `DEBUGPY_LOG_DIR` when starting the target). Either switch also turns pydevd's debug log on inside the debugged program, which slows it: leave them off unless you are diagnosing debugpy itself (issues #1264, #1384).
Loading
Loading