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.WriteKB

Previous Top Next


SPR Script Language

 

HTP.WriteKB

Creates the default SPR Knowledge Base file if it does not already exist.

 

Intention

 

The MCP server's ability to provide help on SPR commands (e.g., via the get_spr_command_info tool) depends on a text file named SPR_Knowledgebase.txt. The HTP.WriteKB command is a setup utility that creates this file with a comprehensive, built-in set of command definitions.

 

It is safe to run this command at the start of any script; it will not overwrite an existing knowledge base file, preserving any custom modifications you may have made.

 

Illustration

📚 Reference Library: If the town library (Knowledge Base file) doesn't exist, this command builds a new one and stocks it with a complete default set of encyclopedias. If the library is already there, it leaves it alone.

 

Syntax

 

HTP.WriteKB[|$$FILEPATH][|$$RET]

 

Parameter Explanation

 

P1 - $$FILEPATH - (Variable, Optional)

A variable containing the full path, including filename, where the Knowledge Base file should be written. If omitted, it defaults to SPR_Knowledgebase.txt in the same directory as the robot executable.

 

P2 - $$RET - (Variable, Optional)

A variable to store the result code. Returns 0 if the file was written, 1 if it already existed, or -1 on error. If omitted, the code is pushed to the stack.

 

Examples

 

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

' HTP.WriteKB - Sample 1: Create the Default KB File

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

' Ensure the default KB file is deleted for this test

DEL.?path\SPR_Knowledgebase.txt

' Create the file

HTP.WriteKB||$$ret

IVV.$$ret=0

 MBX.Knowledge Base file was created successfully.

ELS.

 MBX.Operation finished with code: $$ret

EIF.

ENR.

'

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

' HTP.WriteKB - Sample 2: Create KB at a Custom Path

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

VAR.$$pth=?desktop\MyCustomKB.txt

DEL.$$pth

HTP.WriteKB|$$pth|$$ret

MBX.Operation finished with code: $$ret

ENR.

 

Remarks

 

- This command is a prerequisite for using the AI tool-finding capabilities of the MCP server, such as find_spr_commands_by_category.

- The content written to the file is hardcoded within the HTP library.

 

See also:

 

MCP.Init

HTP.MCPWriteConfig