|
<< 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 - Server Management |
MiniRobot Language (MRL) - MCP Server Management Commands
MCP.RunCommand
Run Command on MCP Server
Purpose
The MCP.RunCommand command executes a system-level command on the MCP server machine. This command provides a secure way to run shell commands, scripts, or executables on the server with proper permission controls and output capture capabilities.
This command is particularly useful when:
• Running server maintenance scripts
• Executing system diagnostics
• Managing files on the server
• Automating server tasks
Syntax
MCP.RunCommand|$$COMMAND|$$ARGS|TIMEOUT|$$RETURN_VAR
Parameters
$$COMMAND - The command or executable to run.
$$ARGS - Command arguments separated by pipes (use empty string if none).
TIMEOUT - Maximum execution time in seconds (0 for no timeout).
$$RETURN_VAR - The variable that will receive the command output and status.
Return Value
The command populates $$RETURN_VAR with a structured result containing:
EXIT_CODE - The command exit code (0 for success)
STDOUT - Standard output from the command
STDERR - Standard error output (if any)
DURATION - Execution time in milliseconds
Examples
' Example 1: List directory contents
MCP.RunCommand|dir|/b|30|$$DirResult
PRT.Directory listing: $$DirResult
' Example 2: Run PowerShell script with timeout
$$ScriptPath=C:\Scripts\backup.ps1
MCP.RunCommand|powershell|-File|$$ScriptPath|300|$$BackupResult
SCH.In|$$BackupResult|EXIT_CODE: 0|$$Success
IVV.$$Success!0
PRT.Backup completed successfully
ELS.
PRT.Backup failed: $$BackupResult
EIF.
' Example 3: Check system information
MCP.RunCommand|systeminfo||60|$$SysInfo
PRT.System info retrieved
Remarks
The MCP.RunCommand command executes commands with the same permissions as the MCP server process. Ensure that proper security controls are in place to prevent unauthorized command execution.
The timeout parameter prevents commands from running indefinitely. If a command exceeds the specified timeout, it is terminated and an error is returned. Set timeout to 0 to disable timeout (not recommended for long-running commands).
Command arguments containing spaces should be properly quoted within the argument string. The server handles proper escaping for the target shell.
Security Considerations
This command has significant security implications. It should only be used when:
• The MCP server is running in a controlled environment
• Proper authentication is configured
• Command whitelist/blacklist is enabled
• Input validation is performed before execution
Error Conditions
The command will fail with an error if:
• The command parameter is missing
• The timeout parameter is invalid
• The return variable parameter is missing
• The command is not found or not executable
• The command execution times out
• The command is blocked by security policy
See also:
• MCP.Signal - Send Signal to MCP Server
• MCP.WriteConfig - Write Configuration