TTMSMCPTools.RegisterTool Method
Creates a tool from a name, a description and a callback in a single call, and appends it to the collection.
API unit family: TMS.MCP.Tools
Declaring type: TTMSMCPTools
Syntax
procedure RegisterTool(const AName, ADescription: string; AToolMethod: TTMSMCPMethod; AReturnType: TTMSMCPToolPropertyType = ptString);
Remarks
The tool is registered without any input parameters, so it publishes an empty input schema and the callback receives no arguments. Add entries to the tool's parameter collection afterwards, or build the tool with the fluent builder instead, whenever it takes input.
Parameters
| Name | Description |
|---|---|
AName |
Name the tool is published under. It must not be blank and must not already be in use. |
ADescription |
Description published with the tool. |
AToolMethod |
Anonymous method run when the tool is invoked, receiving its arguments by position. It must be assigned. |
AReturnType |
Declared type of the value the callback returns, used to convert it to JSON. Defaults to ptString. |
Exceptions
| Exception | Description |
|---|---|
EJsonRpcException |
Raised with an invalid-parameters code when the name is blank, when a tool with the same name already exists, or when the callback is not assigned. |