TsgcWSAPIClient_MCP › Methods › RequestTool
Invokes a named tool on the server (tools/call) with optional JSON arguments.
procedure RequestTool(const aName: string; const aArguments: IsgcJSON = nil);
| Name | Type | Description |
|---|---|---|
aName | const string | Identifier of the tool to invoke, as published by the server in its tools/list catalogue. |
aArguments | const IsgcJSON | Optional JSON payload carrying the arguments required by the tool. Pass nil when the tool takes no arguments. |
Issues the JSON-RPC tools/call request. The server executes the tool and returns structured content (text, images, or embedded resources). Results are delivered through OnMCPResponseTool as a TsgcAI_MCP_Response_ToolsCall instance. The session must be in aimcpstInitialized state. Build aArguments using the helpers exposed by TsgcJSON/IsgcJSON and reuse a single instance across calls by clearing it between requests.
var
oArgs: IsgcJSON;
begin
oArgs := TsgcJSON.Create(nil);
oArgs.AddPair('city', 'Barcelona');
MCP.RequestTool('GetTemperature', oArgs);
end;