MCP. - MCP Server Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Internet and Network > MCP. - MCP (Model-Context Protocol) server operations > !Server-Operations - Commands for interacting with a running MCP server (signals, actions) >

MCP. - MCP Server Operations

HTP.MCPGetStatusByte

Previous Top Next


SPR Script Language

 

HTP.MCPGetStatusByte

Get server startup status. Returns 0=Starting, 1=Ready, 255=Failed.

 

Intention

 

After starting the MCP server with MCP.Start, the server thread begins its initialization in the background. The HTP.MCPGetStatusByte command is a non-blocking way to check on its progress. It allows your main script to wait until the server is fully operational or has failed to start before proceeding.

This is the primary synchronization mechanism to ensure the server is ready to accept signals or commands.

 

Illustration

🚦 Traffic Light: Check the server's status.
🟡 0 (Starting): Yellow light - wait.
🟢 1 (Ready): Green light - go!
🔴 255 (Failed): Red light - stop and check for errors.

 

Syntax

 

HTP.MCPGetStatusByte[|$$ret]

 

Parameter Explanation

 

P1 - $$RET - (Variable, Optional)

A variable (e.g., $$sts) to store the numeric status code. If omitted, the code is pushed to the top of the stack (TOS).

 

Examples

 

'***********************************

' HTP.MCPGetStatusByte - Sample 1: Wait for Server to be Ready

'***********************************

MCP.Init

MCP.Start||$$thr

PRT.Waiting for server to initialize...

:WaitLoop

 HTP.MCPGetStatusByte|$$sts

 ' Status 0 means "Starting", so we wait.

 JIV.($$sts=0)|WaitLoop

 ' Status 1 means "Ready"

IVV.$$sts=1

 MBX.Server is ready!

ELS.

 MBX.Server failed to start! Status code: $$sts

EIF.

MCP.Stop

ENR.

 

Remarks

 

- This command has an alias: HTP.MCPGetStatus.

- The check is instantaneous and does not pause the script; it should be used in a loop with a small PAU. command to avoid consuming excessive CPU while waiting.

 

See also:

 

MCP.Start

MCP.IsRunning

MCP.Stop