Skip to content

feat(mcp): add stop_detached_probe to stop a listed probe by id - #12

Merged
jbachorik merged 2 commits into
mainfrom
feat/mcp_stop_detached_probe
Oct 5, 2026
Merged

jbachorik merged 2 commits into
mainfrom
feat/mcp_stop_detached_probe

Conversation

@jbachorik

@jbachorik jbachorik commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What & why

list_probes (re-enabled in #11) reports probes a client detached from, but the server couldn't act on them: exit_probe and detach_probe only reach probes the current server session deployed. This adds stop_detached_probe (pid, probe_id, optional port). It reconnects to the probe through BTrace's new public Client.connectAndExitProbe and stops it. probe_id accepts a bare id or a whole list_probes line (1: <id> [<class>]).

  • The call is bounded by a 30 s timeout that closes the client, so an unresponsive agent can't hang the MCP request.
  • Skills: btrace-mcp-operations and btrace-probe-lifecycle now hand a probe found by list_probes to stop_detached_probe, after the operator confirms it's no longer needed. The mcp-leftover-probe eval expects the new tool.

Building this exposed that reconnecting to a detached probe never worked in the BTrace agent (the CLI's -r <id> exit hung the same way). That fix and the client API are in btraceio/btrace#967.

How verified

Against a BTrace JAR built from the btraceio/btrace#967 branch:

Gate Result
./gradlew check e2eTest (BTRACE_JAR=…) unit 19 passed, 0 failed; e2e 11 passed, 0 skipped, 0 failed
scripts/validate-marketplace.sh Marketplace validation passed (10 eval cases, 5 plugins, 31 skills)

Before the agent fix, the new e2e case hung for 90 s on the stop call; that's how the agent bug was found.

Coverage notes

  • e2e stopDetachedProbeRemovesTheListedProbe: takes the detached probe's line from list_probes, stops it, requires its @Export counter to freeze, checks the probe drops off list_probes, and checks a second stop is an error.
  • Unit: the schema and the missing-probe_id error; the reflective adapter call; parsing a list_probes line; and the timeout path (the client gets closed and an error is returned).

Not verified / known limitations

Breaking changes / migration

None. This adds a tool.

Links

🤖 Generated with Claude Code

@jbachorik

Copy link
Copy Markdown
Contributor Author

The failing e2e check is the expected dependency failure: the PR-triggered run builds BTrace develop (155b35d), which doesn't have Client.connectAndExitProbe yet (NoSuchMethodException). A manual run against btraceio/btrace#967 (btrace-ref=feat/client_stop_probe, bdcf0ef) passes: https://github.com/btraceio/agent-plugins/actions/runs/37290693610. Re-run once #967 merges.

Base automatically changed from feat/mcp_list_probes to main October 5, 2026 09:53
@jbachorik
jbachorik marked this pull request as ready for review October 5, 2026 09:55
jbachorik and others added 2 commits October 5, 2026 11:57
list_probes reports probes a client detached from, but the server had no
way to act on them: exit_probe and detach_probe only reach probes the
current server session deployed. stop_detached_probe takes a probe id (or
a whole list_probes line), reconnects through the new BTrace
Client.connectAndExitProbe and stops the probe. The call is bounded by a
30 s timeout that closes the client, so an unresponsive agent cannot hang
the MCP request.

Requires a BTrace build with Client.connectAndExitProbe and the agent fix
that keeps detached probes reconnectable.

Verified against a BTrace JAR built from that branch: ./gradlew check
e2eTest -> unit 19 passed, e2e 11 passed (new
stopDetachedProbeRemovesTheListedProbe: probe stops firing, drops off
list_probes, a second stop errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MCP operations and probe lifecycle skills now hand a probe found by
list_probes to stop_detached_probe (after the operator confirms it is no
longer needed) instead of to the CLI, and document the CLI equivalent
btrace -r <probe-id> exit <PID>. The mcp-leftover-probe eval now expects
stop_detached_probe.

Verified: scripts/validate-marketplace.sh passes (10 eval cases,
5 plugins, 31 skills).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jbachorik
jbachorik force-pushed the feat/mcp_stop_detached_probe branch from 6539ffa to 3050be3 Compare October 5, 2026 09:57
@jbachorik
jbachorik merged commit 31ed76f into main Oct 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant