|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > Task Management - Execute code and scripts > MCP Commands - Task Management |
MiniRobot Language (MRL) - MCP Task Management Commands
MCP.RunScriptSync
Execute Script File and Wait for Result
Purpose
The MCP.RunScriptSync command executes a script file synchronously, blocking robot execution until the script completes. This is the script equivalent of RunCodeSync, useful when you need to run an external script and use its output immediately.
This command is particularly useful when:
• Running existing script files that need to complete before continuing
• The script output is required for subsequent robot steps
• Running short utility scripts that complete quickly
• You want simpler code without job tracking
Syntax
MCP.RunScriptSync|$$FILEPATH|$$RETURN_VAR
Parameters
$$FILEPATH - The full path to the script file to execute. The file extension determines the interpreter (e.g., .py for Python, .ps1 for PowerShell, .js for JavaScript).
$$RETURN_VAR - The variable that will receive the script output or error message.
Return Value
The command returns the complete output of the script execution in the specified variable. If the script fails, the variable will contain the error output. The robot execution is blocked until the script completes.
Examples
' Example 1: Run a Python script and get result
MCP.RunScriptSync|C:\Scripts\get_system_info.py|$$SysInfo
PRT.System info: $$SysInfo
' Example 2: PowerShell script with output processing
MCP.RunScriptSync|C:\Scripts\list_services.ps1|$$Services
PRT.Running services:
PRT.$$Services
' Example 3: Batch file execution
MCP.RunScriptSync|C:\Scripts\cleanup_temp.bat|$$CleanupResult
IVV.$$CleanupResult![]
PRT.Cleanup completed successfully
ELS.
PRT.Cleanup failed: $$CleanupResult
EIF.
Remarks
The script file must exist and be accessible at the specified path. The file extension is used to determine the appropriate interpreter. Unlike the async version, this command blocks robot execution until the script completes.
The command captures both stdout and stderr. Standard output is returned on success. There may be a timeout limit to prevent indefinite blocking of long-running scripts.
Scripts run with the same permissions as the MCP server. Ensure scripts are from trusted sources.
Error Conditions
The command will fail with an error if:
• The file path is missing or empty
• The file does not exist at the specified path
• The file extension is not supported
• The return variable parameter is missing
• The script execution times out
See also:
• MCP.RunScriptAsync - Execute Script Asynchronously
• MCP.RunCodeSync - Execute Code Synchronously
• MCP.CheckJobResult - Check Job Result