TsgcWSAPIServer_MCP › Events › OnMCPRequestTool
Raised when a client issues tools/call; populate the response with the tool’s result.
property OnMCPRequestTool: TsgcAI_MCP_Server_OnRequestToolEvent;
// TsgcAI_MCP_Server_OnRequestToolEvent = procedure(Sender: TObject; const aSession: TsgcAI_MCP_Session; const aRequest: TsgcAI_MCP_Request_ToolsCall; const aResponse: TsgcAI_MCP_Response_ToolsCall) of object
—
Fires when the client invokes a registered tool via tools/call. aRequest.Params.Name carries the tool identifier and aRequest.Params.Arguments the JSON arguments validated against the tool’s input schema. Populate aResponse.Result.Content with text, image, audio or resource blocks, and set aResponse.Result.IsError := True when the call fails so the client reports a structured error. Use aSession to scope state to a single caller when needed.
procedure TMainForm.MCPServerMCPRequestTool(Sender: TObject;
const aSession: TsgcAI_MCP_Session; const aRequest: TsgcAI_MCP_Request_ToolsCall;
const aResponse: TsgcAI_MCP_Response_ToolsCall);
begin
if SameText(aRequest.Params.Name, 'ops.generate-plan') then
begin
aResponse.Result.Content.Clear;
aResponse.Result.Content.AddText('Rolling back deployment ' +
aRequest.Params.Arguments.Node['deploymentId'].AsString);
end
else
aResponse.Result.IsError := True;
end;