|
<< 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.Stop
Shut down the MCP server and clean up resources.
Intention
The MCP.Stop command fully terminates the MCP (Multi-Client Protocol) server in an SPR script by sending an "END" signal (via MCP.End) and cleaning up resources like the JSON config handle and critical section. Unlike MCP.End, which only signals termination, this command ensures a complete shutdown after the server was started with MCP.Start, leaving no lingering resources.
Think of it as closing the server’s shop—MCP.Stop turns off the lights, locks the doors, and sweeps the floor, making sure everything’s tidy.
Illustration
🔚 Shutdown: Use MCP.Stop to stop the server.
🧹 Cleanup: All resources are freed, ready for a fresh start!
Syntax
MCP.Stop
Parameter Explanation
This command takes no parameters. It sends an "END" signal and performs cleanup, with no return value.
Examples
'***********************************
' MCP.Stop - Sample 1: Basic Shutdown
'***********************************
MCP.Init
MCP.Start||$$thr
MBX.Server started with thread: $$thr
MCP.Stop
MBX.Server stopped and cleaned up
MBX.Ready
'
'***********************************
' MCP.Stop - Sample 2: Shutdown After Actions
'***********************************
$$cfg=mcp_config.json
MCP.Start|$$cfg|$$thr
HTP.MCPExec|run|calc.exe|$$res
PRT.Execute result: $$res
MCP.Stop
PRT.Server shutdown complete
MBX.Ready
'
Remarks
- Calls HTP_MCP_SignalEnd to queue the "END" signal, then frees the JSON config handle (g_MCP_ConfigDoc) and deletes the critical section.
- Includes a 1-second delay (SLEEP 1000) to ensure the server thread exits before cleanup.
- Does not return a value; errors are logged internally via HTP_SetError if applicable.
Limitations
- Assumes the server was initialized (via MCP.Init); no effect if not.
- No parameters allowed; adding any causes an error in SPR parsing.
- Thread handle from MCP.Start must be closed separately if retained.
See also:
• MCP.Init
• MCP.End