TMCPClient.CallToolAsync#
Inicia uma chamada de tool representada por uma task limitada e devolve seu identificador de acompanhamento.
Declaração#
function CallToolAsync(const Name: String; const ArgumentsJson: String): TMCPTask;Exemplo#
uses Odisseia.Mcp;
function Echo(const Context: TMCPCallContext; const ArgumentsJson: String): String;
begin Result := ArgumentsJson end;
var Server: TMCPServer; Client: TMCPClient; Task: TMCPTask;
begin
Server := TMCPServer.Create;
Server.Transport('inprocess');
Server.Endpoint('mcp-local');
Server.Tool('echo', 'Repete o JSON', False, Echo);
Server.Start;
Client := TMCPClient.Create.Connect;
Task := Client.CallToolAsync('echo', '{"async":true}');
WriteLn(Task.State);
WriteLn(Task.Result);
Client.Close;
Server.Close
end.No provider de conformidade, os resultados esperados são completed e {"async":true}. Requer mcp.client.use, mcp.client.tool.call e mcp.task.use.