|
<< 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 - Queue Management |
MiniRobot Language (MRL) - MCP Queue Management Commands
MCP.ReturnResult
Return Command Result to the Original Caller
Purpose
The MCP.ReturnResult command sends the result of a processed command back to the original caller. This is used in conjunction with MCP.GetNextCommand to implement custom command processors that retrieve commands from the queue, execute them, and return results.
This command is used when:
• Implementing custom command processors
• Returning results from manually processed queue commands
• Sending responses back to external callers
• Completing asynchronous command execution
Syntax
MCP.ReturnResult|$$COMMAND_ID|$$RESULT_DATA|$$RETURN_VAR
Parameters
$$COMMAND_ID - The unique command ID received from MCP.GetNextCommand. This correlates the result with the original command.
$$RESULT_DATA - The result data to return to the caller. This can be a simple value, JSON data, or an error message.
$$RETURN_VAR - The variable that will receive the result code (0 for success, non-zero for error).
Return Value
0 - Result returned successfully
1 - Invalid command ID (command not found or expired)
2 - MCP server not running
3 - Result data too large
Examples
' Example 1: Basic result return
MCP.GetNextCommand|$$Cmd|$$CmdID|$$Status
IVV.$$Status!1
' Process command and generate result
$$Result=Success
MCP.ReturnResult|$$CmdID|$$Result|$$Ret
EIF.
' Example 2: Complete command processor with error handling
MCP.GetCmd|$$Command|$$ID|$$GetStatus
IVV.$$GetStatus!1
' Execute the command
EXC.$$Command|$$ExecResult|$$ExecError
IVV.$$ExecError!0
' Success - return result
MCP.ReturnResult|$$ID|$$ExecResult|$$RetStatus
ELS.
' Error - return error message
$$ErrorMsg=ERROR: $$ExecError
MCP.ReturnResult|$$ID|$$ErrorMsg|$$RetStatus
EIF.
EIF.
' Example 3: Returning JSON result data
MCP.GetNextCommand|$$Cmd|$$CmdID|$$Status
' Build JSON response
$$JSON={"status":"ok","value":42,"timestamp":"2026-02-16"}
MCP.ReturnResult|$$CmdID|$$JSON|$$Result
Remarks
The command ID used with MCP.ReturnResult must be the same ID received from MCP.GetNextCommand. Using an invalid or expired ID will result in an error.
Command IDs have a limited lifetime. If too much time passes between retrieving a command and returning its result, the ID may expire and the return will fail. The exact timeout depends on the MCP server configuration.
Result data should be kept within reasonable size limits. Very large results may be truncated or rejected. For large data transfers, consider using the Memory Bank commands (MEM.STO/MEM.RCL) and returning a reference key instead.
Error Conditions
The command will fail with a parameter error if:
• The command ID parameter is missing or empty
• The return variable parameter is missing
• Too many parameters are provided
See also:
• MCP.GetNextCommand - Get Next Command from Queue
• MCP.Exec - Execute Action on MCP Server