TsgcWSAPIClient_MCPMethods › RequestTool

RequestTool Method

Invokes a named tool on the server (tools/call) with optional JSON arguments.

Syntax

procedure RequestTool(const aName: string; const aArguments: IsgcJSON = nil);

Parameters

NameTypeDescription
aNameconst stringIdentifier of the tool to invoke, as published by the server in its tools/list catalogue.
aArgumentsconst IsgcJSONOptional JSON payload carrying the arguments required by the tool. Pass nil when the tool takes no arguments.

Remarks

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.

Example

var
  oArgs: IsgcJSON;
begin
  oArgs := TsgcJSON.Create(nil);
  oArgs.AddPair('city', 'Barcelona');
  MCP.RequestTool('GetTemperature', oArgs);
end;

Back to Methods