|
<< 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.MCPExec
Execute a predefined action on the MCP server with a value, returning the result code.
Intention
The HTP.MCPExec command triggers a specific action on the MCP (Multi-Client Protocol) server, such as running an executable, SPR script, or callback, based on a predefined configuration. You provide an action name (e.g., "launch_app") and a value (e.g., "notepad.exe"), and it returns a result code (0 for success, or an error code). This allows secure, whitelisted operations to be performed without direct server interaction, assuming the server is initialized with MCP.Init and running via MCP.Start.
Imagine it as handing a task to the server’s assistant—HTP.MCPExec tells it what to do and with what, and you get a quick thumbs-up or thumbs-down.
Illustration
🛠️ Task: Use HTP.MCPExec|run|notepad.exe|$$res to launch Notepad.
✅ Result: $$res returns 0 if it works!
Syntax
HTP.MCPExec|$$act|$$val[|$$ret]
Parameter Explanation
P1 - $$act - (Variable, Required)
A variable containing the action name (e.g., $$act=run), as defined in the server’s config under "actions".
P2 - $$val - (Variable, Required)
A variable containing the value for the action (e.g., $$val=notepad.exe), such as an executable path or parameter.
P3 - $$ret - (Variable, Optional)
A variable to store the result code (e.g., $$ret receives 0 for success, 1+ for errors). If omitted, the result is pushed to the top of the stack (TOS).
Examples
'***********************************
' HTP.MCPExec - Sample 1: Execute a Whitelisted Executable
'***********************************
MCP.Init
MCP.Start||$$thr
HTP.MCPExec|run|notepad.exe|$$res
MBX.Execute result: $$res (0 = success)
MCP.Stop
MBX.Ready
'
'***********************************
' HTP.MCPExec - Sample 2: Execute with Config-Defined Action
'***********************************
$$cfg=mcp_config.json
MCP.Start|$$cfg|$$thr
$$act=launch_app
$$val=calc.exe
HTP.MCPExec|$$act|$$val|$$res
PRT.Action $$act with $$val, result: $$res
MCP.Stop
MBX.Ready
'
Remarks
- Actions are defined in the config file (loaded via MCP.Init) under "actions", with types like "executable", "spr", or "callback".
- Result codes: 0 (success), 1 (unknown action), 2 (execution failed), 3 (unsupported type), 4 (unauthorized executable).
- Does not require the server thread to be running, but config must be loaded.
Limitations
- Requires prior initialization with MCP.Init to load the config.
- Only supports whitelisted executables (e.g., "notepad.exe", "calc.exe") unless config specifies a path.
- SPR and callback actions are placeholders; full implementation is pending.
See also:
• MCP.Init
• MCP.Stop