|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > !Server-Lifecycle - Commands for managing the MCP server lifecycle (init, start, stop) > MCP. - MCP Server Operations |
SPR Script Language
MCP.IsRunning
Checks if the MCP server listener thread is currently active.
Intention
The MCP.IsRunning command provides a simple way to determine the status of the Mini Command Processor (MCP) server. It checks if the main listener thread, started by MCP.MCPStart, is currently active. This is essential for scripts that need to manage the server's lifecycle, ensuring that they don't attempt to start a server that is already running or interact with one that has been stopped.
It’s your robot’s heartbeat monitor—MCP.IsRunning tells you instantly if its command server is online and ready to receive instructions.
Syntax
MCP.IsRunning[|$$RET]
Parameter Explanation
P1 - $$RET - (Variable, Numeric, Optional)
An optional variable to store the result. If omitted, the result is placed on the top-of-stack ($$TOS).
1 = The server thread is running.
0 = The server thread is not running or has not been initialized.
Examples
'***********************************
' MCP.IsRunning - Sample 1: Check server status and start if needed
'***********************************
MCP.IsRunning|$$RES
JNZ.$$RES|Is_Running
PRT.Server is not running. Starting now...
MCP.MCPStart
JIZ.$$TOS|Start_Failed
PRT.Server started successfully.
GTO.End_Check
:Is_Running
PRT.Server is already running.
GTO.End_Check
:Start_Failed
MBX.Error|Failed to start MCP server!
END.
:End_Check
MCP.MCPStop
PRT.Server has been stopped.
END.
Remarks
- This command provides a quick, thread-safe check of the server's status without sending a signal.
- It is useful in startup scripts to prevent attempting to start multiple instances of the server.
See also:
• MCP.Stop