MCP Commands - Testing & Debugging

<< Click to Display Table of Contents >>

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

MCP Commands - Testing & Debugging

MCP.Simulate - Simulate MCP Script Event

PreviousTopNext


MiniRobot Language (MRL) - MCP Testing & Debugging Commands

 

MCP.Simulate

Simulate an MCP Script Event

 

Purpose

 

The MCP.Simulate command generates a simulated MCP event for testing and debugging purposes. This allows developers to test how their scripts respond to various MCP events without needing to trigger the actual conditions that would normally generate those events.

 

This command is particularly useful when:

• Testing event handlers during script development

• Debugging response to MCP events

• Simulating error conditions that are hard to reproduce

• Creating automated tests for MCP integration

• Training and demonstration scenarios

 

Syntax

 

MCP.Simulate|$$EVENT_TYPE|$$EVENT_DATA|$$RETURN_VAR

 

Parameters

 

$$EVENT_TYPE - The type of event to simulate. Supported types include: COMMAND_RECEIVED, QUEUE_FULL, ERROR, STATUS_CHANGE, TOOL_COMPLETED, and CUSTOM.

 

$$EVENT_DATA - Event-specific data in JSON format. The structure depends on the event type being simulated.

 

$$RETURN_VAR - The variable that will receive the result code (0 for success, non-zero for error).

 

Return Value

 

0 - Event simulated successfully

1 - Unknown event type

2 - MCP server not running

3 - Invalid event data format

4 - Event handler not found (no listener for this event type)

 

Examples

 

' Example 1: Simulate a command received event

$$EventData={"command":"MEM.STO|TestKey|TestValue","source":"test"}

MCP.Simulate|COMMAND_RECEIVED|$$EventData|$$Result

PRT.Simulation result: $$Result

 

' Example 2: Simulate an error condition

$$ErrorData={"code":500,"message":"Connection timeout","tool":"FileReader"}

MCP.Simulate|ERROR|$$ErrorData|$$Status

 

' Example 3: Simulate queue full event

$$QueueData={"current_size":100,"max_size":100,"dropped_commands":3}

MCP.Simulate|QUEUE_FULL|$$QueueData|$$SimResult

 

' Example 4: Test event handler with custom event

$$CustomEvent={"type":"user_action","data":{"button":"submit","form_id":123}}

MCP.Simulate|CUSTOM|$$CustomEvent|$$HandlerResult

IVV.$$HandlerResult!0

PRT.Event handled successfully

ELS.

PRT.Event simulation failed: $$HandlerResult

EIF.

 

' Example 5: Simulate tool completion event

$$ToolData={"tool_name":"Screenshot","duration_ms":150,"success":true}

MCP.Simulate|TOOL_COMPLETED|$$ToolData|$$SimStatus

 

Remarks

 

The MCP.Simulate command is designed for testing and debugging purposes only. Simulated events are processed through the same event handlers as real events, allowing you to test your script's response without triggering actual MCP operations.

 

Event data should be provided as a JSON-formatted string. The required fields depend on the event type:

 

COMMAND_RECEIVED: command (string), source (string, optional)

QUEUE_FULL: current_size (number), max_size (number), dropped_commands (number)

ERROR: code (number), message (string), tool (string, optional)

STATUS_CHANGE: old_status (string), new_status (string)

TOOL_COMPLETED: tool_name (string), duration_ms (number), success (boolean)

CUSTOM: type (string), data (any)

 

Error Conditions

 

The command will fail with a parameter error if:

• The event type parameter is missing

• The return variable parameter is missing

• Too many parameters are provided

 

See also:

 

MCP.Exec - Execute Action on MCP Server

MCP.IsRunning - Check if MCP Server is Running

MCP Tool Categories Overview