Repository navigation
Stream progress notifications for tool calls and let clients cancel them - #33
Merged
Merged
Conversation
A long tool call gave the client no feedback and could not be stopped: every request was answered with one JSON response after the tool ended. A tools/call with _meta.progressToken and an Accept header that includes text/event-stream is now answered as a Server-Sent Events stream, in both protocol eras: - the tool calls Report Progress.vi, and each call becomes a notifications/progress event (progress strictly increasing, optional total and message) - the result follows as the last event - Process HTTP Request.vi starts such a call asynchronously and returns the stream at once All other requests are answered exactly as before. Cancellation: - 2026-07-28: the client closes the stream. The framework then stops taking events, which Report Progress.vi and Cancel Requested.vi notice when an event is not taken within about a second. - Older versions: notifications/cancelled is recorded before the request reaches the serialised handler and answered with 202. It reaches streamed calls; a non-streamed call still blocks other requests. - A cancelled call sends no result. New VIs and class: - Report Progress.vi, Cancel Requested.vi (public): the tool side. - MCP SSE Response.lvclass: child of the IG HTTP Utils Streamable Response, takes its chunks from a queue; sets the SSE headers and Transfer-Encoding: chunked. - Prepare Request Dispatch.vi: records legacy cancellations and decides whether a call streams. - Start Streamed Request.vi, Run Streamed Request.vi: run a streamed call asynchronously and end the stream. - Validate MCP Request.vi: the 2026-07-28 request checks, moved out of Handle MCP Request.vi, which now also passes the stream to the tool. - Stream State.vi, Wait For Stream Drain.vi, Get Request Stream.vi, Legacy Cancellations.vi: state and helpers. The readme describes progress and cancellation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
New fixture fake tool progress.vi reports ten steps and stops when told it is cancelled; Progress Fixture Record.vi keeps how far it got; Add Fixture Progress Tool.vi registers it. - Test 58: a call with progressToken streams ten progress events with that token, strictly increasing, then the result (legacy call with a string token, 2026-07-28 call with a numeric token); the same call without a token gets plain JSON - Test 59: a raw TCP client closes the stream after the first event; the tool stops before step 10 and reports cancellation - Test 60: notifications/cancelled for a running streamed call is answered with 202 within a second, the tool stops early and no result is sent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests✅ All 61 tests passed. Per-test results
Protocol tests✅ Protocol tester output (0 failed required checks)VI changesVIs: 4 modified, 21 added, 0 deleted
Added VIs (21)Report for commit 4b310ed. The installable test package is under Artifacts of this run once the build job has finished. |
Brings in the VIPM build timeouts of the live workflows, so this pull request's checks run with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Update: merged |
#31 split Handle MCP Request.vi into one subVI per step, and this branch had changed the old single VI. The binary VI cannot be merged, so this branch's changes are re-applied to the split VIs in place: - Set MCP Request Context.vi gets a "stream" input and adds "id", "progressToken" and "stream" to the request context. - Handle MCP Request.vi passes its new "stream" input on to it. - Prepare Request Dispatch.vi calls Read MCP Request Metadata.vi and Check Modern MCP Request.vi instead of Validate MCP Request.vi. Validate MCP Request.vi is no longer called anywhere and is removed from the library and the repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Update: rebuilt on #31's split
|
metman-oss
pushed a commit
to metman-oss/LabVIEW-MCP-Server-Toolkit
that referenced
this pull request
Oct 31, 2026
Ask User.vi, Confirm With User.vi, Report Progress.vi and Cancel Requested.vi are public since JanGoebel#31 and JanGoebel#33, but the package's Functions palette still listed only Start, Add Tool, Add Prompt, Add Resource (File) and Stop, with Stop twice (once at row 0, outside the visible grid). The MCP Server SDK palette now has one row with the five basic VIs and an "Advanced" sub-palette below them, holding the four VIs a tool calls while it runs: Ask User, Confirm With User, Report Progress and Cancel Requested. The duplicate Stop entry is gone. The sub-palette icon follows the style VIPM generated for the main palette icon (text on white, the company band at the bottom). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

























Summary
Long-running tools can now report progress, and clients can cancel them.
A
tools/callthat asks for progress gets a Server-Sent Events stream: anotifications/progressevent for everyReport Progress.vicall, then the result. That means_meta.progressTokenplusAccept: text/event-stream.When the client cancels,
Report Progress.vi/Cancel Requested.vireturn TRUE and the tool can stop. A 2026-07-28 client cancels by closing the stream; an older one by sendingnotifications/cancelled.notifications/progressevents while it runscancelled?and can stop; no result is sentnotifications/cancelled(older clients)cancelled?Changes
Report Progress.vi,Cancel Requested.vi(new, public): the tool side.cancelled?.MCP SSE Response.lvclass(new): child ofHTTP Utils.lvlib:Streamable Response.Next Segmentoverride, which takes the next event from a queue.Stream Lengthreturns -1 andAbort Streamsets a flag.Create MCP SSE Response.visetsContent-Type: text/event-stream,Cache-Control: no-cache,X-Accel-Buffering: noandTransfer-Encoding: chunked. The IG server frames chunks but does not send that last header itself.Process HTTP Request.vi(modified):Prepare Request Dispatch.vi(new):notifications/cancelledand answers 202 before the request reaches the serialised handlerStart Streamed Request.vi,Run Streamed Request.vi(new):Handle MCP Request.viasynchronouslyHandle MCP Request.vi(modified, regenerated; it was generated in Serve MCP 2026-07-28 next to the initialize handshake, with elicitation #31): passes the stream, the id and the progressToken to the tool through the request context. Its 2026-07-28 checks moved unchanged intoValidate MCP Request.vi(new).Stream State.vi,Wait For Stream Drain.vi,Get Request Stream.vi,Legacy Cancellations.vi(the last 16 cancelled ids).readme.md: new section on progress and cancellation.fake tool progress.vi,Progress Fixture Record.viandAdd Fixture Progress Tool.vi.How a closed stream is noticed
The IG HTTP Server does not tell a response object that its client went away: a failed chunk write just ends its streaming loop, and
Abort Streamis not called. OverridingWrite Response to Streamto catch that needs a wired Call Parent Method node, which the generation tools cannot produce.So cancellation is noticed by drain instead:
Report Progress.viwaits up to 1 s for its event to be taken.Cancel Requested.visends an SSE keep-alive comment (:) at most every 500 ms and checks it the same way.Code summary
Process HTTP Request.viAcceptand dispatches through Prepare Request DispatchPrepare Request Dispatch.viStart Streamed Request.viRun Streamed Request.viMCP SSE Response.lvclassReport Progress.vi,Cancel Requested.viWait For Stream Drain.vi,Stream State.vi,Get Request Stream.vi,Legacy Cancellations.viHandle MCP Request.vi,Validate MCP Request.viProcess HTTP Request.vi— modifiedAcceptheader (Select Value.vimpicks the first value).Mcp-MethodandMcp-Nameas in Serve MCP 2026-07-28 next to the initialize handshake, with elicitation #31.Allow: POSTto a refused GET.Dispatch case, True frame:
Prepare Request Dispatch.vi— addednotifications/cancellednotification with a string or numberparams.requestIdis recorded inLegacy Cancellations.viand answered with 202. Nothing else runs for it.tools/call…_meta.progressTokenof type string or number…Acceptheader containingtext/event-stream.stream?tells Process HTTP Request to start the call asynchronously. For a 2026-07-28 request, Validate MCP Request runs first, so a refused request never streams.Start Streamed Request.vi,Run Streamed Request.vi— addedStart Streamed Request, True frame (the call streams):
Run Streamed Request.vi…Ctrl Val.Set.Run Streamed Request resets the stream state, calls
Handle MCP Request.viwith the stream in the request context, then enqueuesdata: <final response>unless the call was cancelled, and always the end marker. The False frame of Start Streamed Request only releases both queues, for a call that does not stream after all.MCP SSE Response.lvclass— addedStream Lengthreturns -1, so the IG server streams in chunks and callsNext SegmentuntilLast?.Create MCP SSE Response.visetsContent-Type: text/event-stream,Cache-Control: no-cache,X-Accel-Buffering: no,Transfer-Encoding: chunkedand status 200.Abort Streamsets the cancelled flag.Next Segment.vi:Last?with":"as the last data, an SSE comment, so no second zero-length chunk is written.Report Progress.vi,Wait For Stream Drain.vi— addeddata: {"jsonrpc":"2.0","method":"notifications/progress","params":{"progressToken":…,"progress":…,"total"?:…,"message"?:…}}, with the token as sent (string or number).notifications/cancelledfor this request id also returnscancelled?TRUE.Cancel Requested.vidoes the same check with a keep-alive comment (:), at most every 500 ms.Wait For Stream Drain.vi:Tests — added
test progress notifications.vi): a legacy call with the string token"t58"and a 2026-07-28 call with the numeric token583each stream ten progress events, strictly increasing, then the result. The same call without a token gets plain JSON.test progress cancel by close.vi): a raw TCP client closes the stream after the first event; the tool stops before step 10 and reports cancellation.test progress legacy cancel.vi):notifications/cancelledfor a running streamed call gets 202 within 1 s; the tool stops early and no result is sent.fake tool progress.vi,Progress Fixture Record.vi,Add Fixture Progress Tool.vi.Verified
On the runner: all 61 Caraya tests and the protocol tester passed, and all VIs were compared. The package build fails for every pull request until #32 is applied.
Locally, in 64-bit LabVIEW 2026, inside the project, after a fresh project load:
notifications/cancelledwas answered with 202 at once and stopped the tool after 1 stepNot verified
Known rough edges
Select Value.vimis insrc/MCP Serverbut not a library member.Process HTTP Request.vilinks to it unqualified, and adding it hit LabVIEW error 56003.Handle MCP Request.viis regenerated: 161 kB against 344 kB before, from the smaller diagram, with the same logic and its icon kept.Maintainer steps
None. Merge #30 and #31 first.
🤖 Generated with Claude Code