#1 2026-01-05 10:31:28

bigheart
Member
Registered: 2014-08-01
Posts: 55

Need a MCP Client example

Hi all,

Does anyone can advise some example for the MCP client with "generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash" using mormot2?
MCP Server is installed on local using python.

I just have a code for the  call zemini api as below:

...
    LHttpClient := THttpClientSocket.Create(3000);
    try
      LHttpClient.TLS.IgnoreCertificateErrors := True;
       LHttpClient.Open(LHost, LPort, nlTcp, 20000, True);

      LDictText.S['text'] := StringToUtf8(APrompt);
      LListParts.AppendDoc(LDictText);
      LDictParts.A['parts'] := LListParts;
      LListContents.AppendDoc(LDictParts);
      LDictContents.A['contents'] := LListContents;

      LDictthinkingConfig.I['thinkingBudget'] := 0;
      LDictgenerationConfig.D['thinkingConfig'] := LDictthinkingConfig;
      LDictContents.D['generationConfig'] := LDictgenerationConfig;
      LJsonBody := LDictContents.Json;
      LHttpClient.HeaderAdd('x-goog-api-key:' + ApiKey);
      Result := LHttpClient.Request(LPath, 'POST', DEFAULT_TIMEOUT_MS, LHttpClient.Headers, LJsonBody, 'application/json');
      ARespond := Utf8ToString(LHttpClient.Http.Content); 

      if Result <> 200 then
      begin
        raise Exception.CreateFmt('API call fail: status code is %d, msg: %s', [Result, string(LHttpClient.Http.Content)]);
      end;
    finally
      LHttpClient.Free; 
    end;
...

Have fun mormot.

Last edited by bigheart (2026-01-05 10:31:55)

Offline

#2 2026-01-06 18:21:17

zen010101
Member
Registered: 2024-06-15
Posts: 167

Re: Need a MCP Client example

Offline

Board footer

Powered by FluxBB