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
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ A tool can ask the user a question while it runs, for example to confirm before
- If the client cannot ask (older protocol, or no `elicitation` capability), the VI returns `not supported`. The tool decides what to do then: refuse with an error, or use a safe default.
- Never use it to ask for passwords or keys.

## Progress and cancellation

Long-running tools can report progress and stop when the client cancels.

- `Report Progress.vi` (progress, optional total and message) sends a `notifications/progress` event to the client. It returns `cancelled?`. Stop the tool when it is TRUE.
- `Cancel Requested.vi` returns `cancelled?`, for loops that do not report progress.
- Progress is streamed only when the client asks for it: `tools/call` with `_meta.progressToken`, and an `Accept` header that includes `text/event-stream`. The answer is then a Server-Sent Events stream: the progress events, then the result. Without that, both VIs do nothing and return FALSE.
- Cancelling works in two ways:
- MCP 2026-07-28 clients cancel by closing the stream.
- Older clients send `notifications/cancelled`.
- Either way, the next `Report Progress.vi` / `Cancel Requested.vi` call returns TRUE.
- A closed stream is noticed when an event is not taken within about one second.
- `notifications/cancelled` only reaches a streamed call. A non-streamed call blocks other requests until it ends.

## Dependencies
This toolkit uses IG HTTP Server Toolkit and JKI JSONtext.

Expand Down
Binary file added src/MCP Server/Cancel Requested.vi
Binary file not shown.
Binary file added src/MCP Server/Get Request Stream.vi
Binary file not shown.
Binary file modified src/MCP Server/Handle MCP Request.vi
Binary file not shown.
Binary file added src/MCP Server/Legacy Cancellations.vi
Binary file not shown.
Binary file added src/MCP Server/MCP SSE Response/Abort Stream.vi
Binary file not shown.
Binary file not shown.
Binary file added src/MCP Server/MCP SSE Response/Get Queues.vi
Binary file not shown.
69 changes: 69 additions & 0 deletions src/MCP Server/MCP SSE Response/MCP SSE Response.lvclass

Large diffs are not rendered by default.

Binary file added src/MCP Server/MCP SSE Response/Next Segment.vi
Binary file not shown.
Binary file added src/MCP Server/MCP SSE Response/Stream Length.vi
Binary file not shown.
12 changes: 12 additions & 0 deletions src/MCP Server/MCP Server.lvlib
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<Item Name="Stop.vi" Type="VI" URL="../Stop.vi"/>
<Item Name="Ask User.vi" Type="VI" URL="../Ask User.vi"/>
<Item Name="Confirm With User.vi" Type="VI" URL="../Confirm With User.vi"/>
<Item Name="Report Progress.vi" Type="VI" URL="../Report Progress.vi"/>
<Item Name="Cancel Requested.vi" Type="VI" URL="../Cancel Requested.vi"/>
</Item>
<Item Name="Private" Type="Folder">
<Property Name="NI.LibItem.Scope" Type="Int">4</Property>
Expand Down Expand Up @@ -129,13 +131,23 @@
<Item Name="Handle MCP Request.vi" Type="VI" URL="../Handle MCP Request.vi"/>
<Item Name="Cache Hints.vi" Type="VI" URL="../Cache Hints.vi"/>
<Item Name="Build Unsupported Version Error.vi" Type="VI" URL="../Build Unsupported Version Error.vi"/>
<Item Name="Stream State.vi" Type="VI" URL="../Stream State.vi"/>
<Item Name="Legacy Cancellations.vi" Type="VI" URL="../Legacy Cancellations.vi"/>
<Item Name="Wait For Stream Drain.vi" Type="VI" URL="../Wait For Stream Drain.vi"/>
<Item Name="Get Request Stream.vi" Type="VI" URL="../Get Request Stream.vi"/>
<Item Name="Prepare Request Dispatch.vi" Type="VI" URL="../Prepare Request Dispatch.vi"/>
<Item Name="Run Streamed Request.vi" Type="VI" URL="../Run Streamed Request.vi"/>
<Item Name="Start Streamed Request.vi" Type="VI" URL="../Start Streamed Request.vi"/>
<Item Name="MCP Request Metadata.ctl" Type="VI" URL="../MCP Request Metadata.ctl"/>
<Item Name="Read MCP Request Metadata.vi" Type="VI" URL="../Read MCP Request Metadata.vi"/>
<Item Name="Check Modern MCP Request.vi" Type="VI" URL="../Check Modern MCP Request.vi"/>
<Item Name="Set MCP Request Context.vi" Type="VI" URL="../Set MCP Request Context.vi"/>
<Item Name="Collect MCP Input Requests.vi" Type="VI" URL="../Collect MCP Input Requests.vi"/>
<Item Name="Complete Modern MCP Result.vi" Type="VI" URL="../Complete Modern MCP Result.vi"/>
</Item>
<Item Name="SSE" Type="Folder">
<Item Name="MCP SSE Response.lvclass" Type="LVClass" URL="../MCP SSE Response/MCP SSE Response.lvclass"/>
</Item>
<Item Name="Webserver" Type="Folder">
<Item Name="MCP Handler.lvclass" Type="LVClass" URL="../MCP Handler/MCP Handler.lvclass"/>
</Item>
Expand Down
Binary file added src/MCP Server/Prepare Request Dispatch.vi
Binary file not shown.
Binary file modified src/MCP Server/Process HTTP Request.vi
Binary file not shown.
Binary file added src/MCP Server/Report Progress.vi
Binary file not shown.
Binary file added src/MCP Server/Run Streamed Request.vi
Binary file not shown.
Binary file added src/MCP Server/Select Value.vim
Binary file not shown.
Binary file modified src/MCP Server/Set MCP Request Context.vi
Binary file not shown.
Binary file added src/MCP Server/Start Streamed Request.vi
Binary file not shown.
Binary file added src/MCP Server/Stream State.vi
Binary file not shown.
Binary file added src/MCP Server/Wait For Stream Drain.vi
Binary file not shown.
Binary file added tests/Add Fixture Progress Tool.vi
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/MCP Server tests.lvlib
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<Item Name="fake tool no description.vi" Type="VI" URL="../fake tool no description.vi"/>
<Item Name="fake tool no inputs outputs.vi" Type="VI" URL="../fake tool no inputs outputs.vi"/>
<Item Name="fake tool picture outputs.vi" Type="VI" URL="../fake tool picture outputs.vi"/>
<Item Name="fake tool progress.vi" Type="VI" URL="../fake tool progress.vi"/>
<Item Name="fake tool return error.vi" Type="VI" URL="../fake tool return error.vi"/>
<Item Name="fake tool required input.vi" Type="VI" URL="../fake tool required input.vi"/>
<Item Name="fake tool special labels.vi" Type="VI" URL="../fake tool special labels.vi"/>
Expand All @@ -42,10 +43,12 @@
<Item Name="Add Fixture Files.vi" Type="VI" URL="../Add Fixture Files.vi"/>
<Item Name="Add Fixture Picture Tool.vi" Type="VI" URL="../Add Fixture Picture Tool.vi"/>
<Item Name="Add Fixture Prompt.vi" Type="VI" URL="../Add Fixture Prompt.vi"/>
<Item Name="Add Fixture Progress Tool.vi" Type="VI" URL="../Add Fixture Progress Tool.vi"/>
<Item Name="Add Fixture Schema Shapes Tool.vi" Type="VI" URL="../Add Fixture Schema Shapes Tool.vi"/>
<Item Name="Add Fixture Schema Details Tool.vi" Type="VI" URL="../Add Fixture Schema Details Tool.vi"/>
<Item Name="Add Fixture Special Labels Tool.vi" Type="VI" URL="../Add Fixture Special Labels Tool.vi"/>
<Item Name="Add Fixture Tool.vi" Type="VI" URL="../Add Fixture Tool.vi"/>
<Item Name="Progress Fixture Record.vi" Type="VI" URL="../Progress Fixture Record.vi"/>
<Item Name="Send HTTP request (custom).vi" Type="VI" URL="../Send HTTP request (custom).vi"/>
<Item Name="Send HTTP request.vi" Type="VI" URL="../Send HTTP request.vi"/>
</Item>
Expand Down Expand Up @@ -75,6 +78,9 @@
<Item Name="test prompt without arguments.vi" Type="VI" URL="../test prompt without arguments.vi"/>
<Item Name="test prompts list required.vi" Type="VI" URL="../test prompts list required.vi"/>
<Item Name="test prompts list.vi" Type="VI" URL="../test prompts list.vi"/>
<Item Name="test progress cancel by close.vi" Type="VI" URL="../test progress cancel by close.vi"/>
<Item Name="test progress legacy cancel.vi" Type="VI" URL="../test progress legacy cancel.vi"/>
<Item Name="test progress notifications.vi" Type="VI" URL="../test progress notifications.vi"/>
<Item Name="test protocol version negotiation.vi" Type="VI" URL="../test protocol version negotiation.vi"/>
<Item Name="test protocol version fallback.vi" Type="VI" URL="../test protocol version fallback.vi"/>
<Item Name="test request status.vi" Type="VI" URL="../test request status.vi"/>
Expand Down
Binary file added tests/Progress Fixture Record.vi
Binary file not shown.
Binary file modified tests/Test_MCP_Server.vi
Binary file not shown.
Binary file added tests/fake tool progress.vi
Binary file not shown.
Binary file added tests/test progress cancel by close.vi
Binary file not shown.
Binary file added tests/test progress legacy cancel.vi
Binary file not shown.
Binary file added tests/test progress notifications.vi
Binary file not shown.
Loading