|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > !Server-Operations - Commands for interacting with a running MCP server (signals, actions) > !Listener-Queue - Commands for managing the Listener Mode queue > MCP. - MCP Server Operations |
SPR Script Language
HTP.MCPResetQue
Clears all pending commands from the MCP Listener server's queue.
Intention
The HTP.MCPResetQue command is used to instantly and completely empty the command queue of an MCP server running in Listener Mode. This is useful for discarding any unprocessed commands to ensure a clean state before starting a new series of operations or when handling an error condition.
Think of it as hitting the "clear all" button on a calculator—it wipes the slate clean, ensuring no old data interferes with your next calculation.
Illustration
🗑️ Empty Queue: Commands [A, B, C] are waiting.
HTP.MCPResetQue
✔️ Result: The queue is now empty [].
Syntax
HTP.MCPResetQue
Parameter Explanation
This command takes no parameters.
Examples
'***********************************
' HTP.MCPResetQue - Sample Usage
'***********************************
' Start the server in Listener Mode (1)
MCP.Start||1|$$thr
JIZ.$$thr|Fail
PAU.500|ms
' Send a command to the server using a TCP client
TCP.Open|127.0.0.1|5556|$$sock
TCP.Send|$$sock|{"action":"test"}
TCP.Close|$$sock
PAU.200|ms
' Verify the queue now contains 1 item
HTP.MCPGetQueueCount|$$count
PRT.Items in queue before reset: $$count
' Reset the queue
HTP.MCPResetQue
PRT.Queue has been reset.
' Verify the queue is now empty
HTP.MCPGetQueueCount|$$count
PRT.Items in queue after reset: $$count
MCP.Stop
Remarks
- This command is thread-safe. It uses a critical section to prevent conflicts with the server thread that adds items to the queue.
- It calls the backend MCP_ResetQueue() function, which uses the RESET statement on the underlying array and resets the ring buffer's head and tail pointers.
Limitations
- This command has no effect if the server is not running or if it is running in Executor Mode, as the Executor Mode does not use this public command queue.
See also: