Skip to content

MCP: progress notifications for long scans, and cancellation - #536

Merged
fstubner merged 2 commits into
mainfrom
feat/mcp-progress-cancel
Oct 6, 2026
Merged

fstubner merged 2 commits into
mainfrom
feat/mcp-progress-cancel

Conversation

@fstubner

@fstubner fstubner commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Gap 2 from the audit.

Progress. discover_network, scan_ports and sweep_network send notifications/progress when the request carries _meta.progressToken. The core already reported per-port and per-host progress; server/progress.rs maps each operation's phases onto one 0 to 1000 scale (the protocol requires progress to only increase), and sends at most one notification every 250 ms, plus the final one.

Cancellation. notifications/cancelled with a requestId aborts that request's task (server/inflight.rs), and no response is sent for it, as the protocol asks. Before, the call ran to the end and held one of the 16 request slots.

End to end on netscli serve (release build):

--- sweep_network with progress
  0.02s     2/1000  pinging: 1 of 254, 1 found
  0.28s    28/1000  pinging: 18 of 254, 18 found
  0.76s    31/1000  pinging: 20 of 254, 18 found
  1.54s   522/1000  scanning hosts: 1 of 23, 0 found
  2.04s   848/1000  scanning hosts: 16 of 23, 10 found
  2.05s  1000/1000  scanning hosts: 23 of 23, 11 found
  2.05s  response id 1 (result)
--- cancel a long scan (4,096 ports, cancelled after 1 s)
  1.00s  response id 3
id 3 answered: True | id 2 answered: False

The jump from 31 to 522 is the ping phase: most pings finish together at the 1 s timeout, so progress there moves in a step.

Tests: throttling, never going backwards, phase mapping, no reporter without a token, cancel aborts a running task, unknown ids ignored, 1 and "1" kept apart. The cancel test fails with the abort removed.

Docs: a "Progress and cancelling" section in the MCP page. CHANGELOG under Unreleased.

Progress: discover_network, scan_ports and sweep_network send
notifications/progress when the request carries _meta.progressToken. The
core already reports per-port and per-host progress; server/progress.rs
maps each operation's phases onto one 0-1000 scale so the count only
rises, and sends at most one notification per 250 ms plus the final one.
The reporter is a task-local set around the request, read only by those
three operations.

Cancellation: notifications/cancelled with a requestId aborts that
request's task (server/inflight.rs), and no response is sent for it, as
the protocol asks. Before, the call ran to the end holding a request slot.

End to end on netscli serve: a /24 sweep sent 6 progress notifications in
2.05 s ending at 1000/1000; a 4,096-port scan cancelled after 1 s was
never answered while a tools/list sent after the cancel was answered at
once. Tests cover throttling, monotonic progress, phase mapping and
cancel; the cancel test fails with the abort removed.
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Site preview: https://pr-536.netscli-site-preview.pages.dev

Built from 21e0084 with NETSCLI_PREVIEW=1 — noindex, and analytics disabled so it does not report into netscli.com's numbers.

Production is unaffected: netscli.com is served from GitHub Pages via pages.yml, which is manual-only.

@fstubner
fstubner merged commit bf00f73 into main Oct 6, 2026
16 checks passed
@fstubner
fstubner deleted the feat/mcp-progress-cancel branch October 6, 2026 01:23
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