|
<< 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 |
SPR Script Language
HTP.MCPStatus
Sends a "STATUS" signal to a running MCP server and waits for a response.
Intention
The HTP.MCPStatus command provides a way to synchronously query the state of the MCP server from another script or process. It sends a signal and blocks execution until the server thread responds or a timeout occurs. The response is a descriptive string containing server information, such as the port it's listening on and the current number of queued clients.
This is useful for health checks, monitoring, or ensuring the server is ready before sending it commands.
Syntax
HTP.MCPStatus[|$$TMO|$$RET]
Parameter Explanation
P1 - $$TMO - (Variable, numeric, Optional)
The maximum time to wait for a response from the server, in milliseconds. If omitted or 0, a default timeout of 5000ms (5 seconds) is used.
P2 - $$RET - (Variable, String, Optional)
The variable to store the result string. The result is formatted as: "ResultCode ResponseText".
0 - Success. The response text contains the server status.
-1 - Failure. The response text contains an error message (e.g., timeout, queue full).
Examples
'***********************************
' HTP.MCPStatus - Sample 1: Get server status
'***********************************
' First, ensure the server is running
MCP.MCPStart
SLE.200
' Send the status signal and wait up to 2 seconds
HTP.MCPStatus|2000|$$RES
MBX.Status Result:|$$RES
MCP.MCPStop
END.
Remarks
- This command is synchronous and will pause the script until a response is received or the timeout is reached.
- The command will fail if the MCP server is not running or if the signal queue is full.
See also: