|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > MCP Commands - Task Management |
MiniRobot Language (MRL) - MCP Server Feature
MCP Task Management
Execute Code and Scripts with Job Control
What is Task Management?
The MCP Task Management system provides powerful execution capabilities for running code and scripts either synchronously (blocking) or asynchronously (non-blocking). It enables robots to execute complex operations, manage long-running tasks, and coordinate multiple concurrent jobs.
Key Features
• Synchronous Execution: Run code/scripts and wait for immediate results
• Asynchronous Execution: Start jobs in background and retrieve results later
• Job Tracking: Unique Job IDs for monitoring and managing tasks
• Timeout Control: Configurable execution timeouts for safety
• Result Retrieval: Check status and retrieve results of completed jobs
Available Commands
Code Execution Commands:
MCP.RunCodeSync - Execute raw SPR code synchronously and return result
MCP.RunCodeAsync - Execute raw SPR code asynchronously (returns Job ID)
Script Execution Commands:
MCP.RunScriptSync - Run a script file synchronously and return result
MCP.RunScriptAsync - Run a script file asynchronously (returns Job ID)
Job Management Commands:
MCP.CheckJobResult / MCP.TaskCheckResult - Check job status without blocking
MCP.WaitForJobResult / MCP.WJR - Wait for job completion (blocking)
MCP.GetJobResult - Retrieve result of a completed job
MCP.GetJobIdList - List all active and pending job IDs
MCP.CleanupJobs - Clean up old completed job records
Sync vs Async Execution
Synchronous (Sync):
• Blocks until execution completes
• Returns result directly
• Simpler error handling
• Good for: Quick operations, sequential logic
Asynchronous (Async):
• Returns immediately with Job ID
• Execute continues in background
• Check status later using Job ID
• Good for: Long operations, parallel execution
Example Usage
Example 1: Synchronous Execution
' Execute code and wait for result
MCP.RunCodeSync|$$Code|$$Result|5000
LBL.|Result: $$Result
Example 2: Asynchronous with Result Check
' Start async job
MCP.RunCodeAsync|$$Code|$$JobID
LBL.|Started job: $$JobID
' ... do other work ...
' Check if complete
MCP.CheckJobResult|$$JobID|$$Status|$$Content
IVV.$$Status!Complete
LBL.|Job complete: $$Content
EIV.
Important Notes
• Job IDs are unique strings that identify each async task
• Completed jobs are retained until MCP.CleanupJobs is called or auto-cleanup runs
• Timeout values are in milliseconds (0 = no timeout)
• Async jobs run in separate threads - beware of shared resource conflicts
• The TASKS capability must be enabled in MCP server configuration
See Also