MCP Commands - Queue Management

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations >

MCP Commands - Queue Management

MCP Queue Management - Overview

PreviousTopNext


MiniRobot Language (MRL) - MCP Server Feature

 

MCP Queue Management

Listener Mode Command Queue System

 

What is Queue Management?

 

The MCP Queue Management system provides control over how commands are buffered, ordered, and processed when the MCP server is operating in Listener Mode. It allows robot scripts to configure queue behavior, monitor queue status, and manage command execution order.

 

Key Features

 

Configurable Queue Size: Set maximum number of pending commands

Multiple Queue Modes: FIFO, LIFO, and Priority-based processing

SLL Implementation: Core queue operations in MCP server files

Runtime Monitoring: Check queue count and mode during execution

Queue Control: Reset and retrieve commands from the queue

 

Available Commands

 

Configuration Commands:

MCP.ConfigQueue - Configure the listener queue (max size, mode, timeout)

 

Management Commands:

MCP.ResetQueue - Clear all pending commands and reset queue state

MCP.GetQueueCount - Get the current number of commands in queue

MCP.GetQueueMode - Get the current queue processing mode

 

Processing Commands:

MCP.GetNextCommand - Retrieve and remove the next command from queue

 

SLL Implementation

 

The queue operations are implemented in the core MCP server files using the Singly Linked List (SLL) data structure. This provides efficient insertion, removal, and traversal operations for managing the command queue:

 

ConfigQueue - Initializes queue with specified parameters

ResetQueue - Clears all nodes and resets pointers

GetQueueCount - Traverses SLL to count active nodes

GetQueueMode - Returns current processing mode setting

GetNextCommand - Dequeues head node based on current mode

 

Listener Mode

 

Listener Mode allows the MCP server to accept and queue commands from external sources (such as AI assistants, other scripts, or network clients) while continuing to process them in a controlled manner. When Listener Mode is enabled:

 

• Incoming commands are placed in the queue

• Commands are processed according to the configured mode

• Queue depth can be monitored to prevent overflow

• The queue can be reset to clear pending commands

 

Queue Modes

 

FIFO (First-In, First-Out):

• Commands are processed in the order they are received

• Default mode for predictable execution order

• Oldest commands are processed first

• Best for: Sequential operations, dependency chains

 

LIFO (Last-In, First-Out):

• Most recent commands are processed first

• Useful for undo/redo operations or stack-like behavior

• Newest commands take priority

• Best for: Undo stacks, recent-priority tasks

 

Priority Mode:

• Commands are processed based on assigned priority levels

• Higher priority commands jump ahead of lower priority ones

• Within same priority, FIFO order is maintained

• Best for: Mixed criticality operations, real-time responses

 

Typical Workflow

 

' Step 1: Start the MCP server

MCP.Start|$$Handle

 

' Step 2: Configure the queue for FIFO with 100 command limit

MCP.ConfigQueue|100|FIFO|5000|$$ConfigResult

 

' Step 3: Monitor queue during processing

LBL.MonitorLoop

MCP.GetQueueCount|$$Pending

PRT.Commands pending: $$Pending

WAI.500

JMP.MonitorLoop

 

' Step 4: Reset queue if needed

MCP.ResetQueue|$$ResetStatus

 

' Step 5: Stop the server

MCP.Stop

 

Important Notes

 

• Queue Management commands require the MCP server to be running

• Changing queue configuration may affect commands already in queue

• Use MCP.ResetQueue with caution - pending commands are lost

• Queue mode affects the order in which GetNextCommand returns items

• Maximum queue size of 0 means unlimited (limited only by system memory)

 

See also:

 

MCP.ConfigQueue - Configure Queue

MCP.ResetQueue - Reset Queue

MCP.GetQueueCount - Get Queue Count

MCP.GetQueueMode - Get Queue Mode

MCP.GetNextCommand - Get Next Command

MCP Server Lifecycle