TMS AI + C++ Builder

I tried to make my first steps with AI Components in Combination with C++ Builider. Specifically MCP-Servers are interesting for us.
I can't make it to work. So maybe you can help me.

I tried to build the Weather-Example. Is the Builder Pattern working with C++ Builder? I didn't managed to make it work. So i tried the traditinal way. With this it works better, but i am struggling to add a Method for my tool.

Here's the Code:

void __fastcall TForm6::btnStartenClick(TObject *Sender)
{
	this->TMSMCPServer->Start();
	TTMSMCPTool *pTool = this->TMSMCPServer->Tools->Add();
	pTool->Name = L"WeatherRequest";
	pTool->Description = L"Gets the Weather for a specific City";
	pTool->ReturnType = ptString;
	pTool->Method = this->GetWeather;

	TTMSMCPToolProperty *pProperty = pTool->Properties->Add();
	pProperty->Name = L"City";
	pProperty->Description = L"Specifies the City for which to get the Weather";
	pProperty->Type = ptString;
	pProperty->Required = true;

	this->Memo->Lines->Add(L"Server started");
}
//---------------------------------------------------------------------------

TValue __fastcall TForm6::GetWeather(const DynamicArray<TValue> &args)
{
	return TValue::From<String>(L"Sunny");
}
//---------------------------------------------------------------------------

Can you point me in the right direction?

An additional Question: Attributes for MCP-Server as in Delphi - are these going to work in C++ Builder? These would be very conveniant for us.

Thank you!

Hi,

You could try the following code and see if that works for your implementation:

        FormatSettings.DecimalSeparator = '.';

         _di_TTMSMCPMethod WeatherCallback = _di_TTMSMCPMethod(
            [](const TValue *Args, const NativeInt Args_High) -> TValue
            {
              //code logic
            }
        );

        TTMSMCPToolBuilder::Initialize();
        TTMSMCPToolBuilder::Name("get_weather");
        TTMSMCPToolBuilder::Description("Get current weather information for a specified city");
        TTMSMCPToolBuilder::ExecuteCallback(WeatherCallback);
        TTMSMCPToolBuilder::ReturnType(ptJSON);

        TTMSMCPToolBuilder::AddProperty();
        TTMSMCPToolPropertyBuilder::Name("city");
        TTMSMCPToolPropertyBuilder::Description("The city name to get weather for");
        TTMSMCPToolPropertyBuilder::PropertyType(ptString);
        TTMSMCPToolPropertyBuilder::Required(false);
        TTMSMCPToolPropertyBuilder::End();

        TTMSMCPTool* Tool = TTMSMCPToolBuilder::Build();

        TTMSMCPServerBuilder::Initialize();
        TTMSMCPServerBuilder::Name("WeatherServer");
        TTMSMCPServerBuilder::ServerVersion("1.0.0");
        TTMSMCPServer* Server = TTMSMCPServerBuilder::Build();

        Server->Tools->Add(Tool);
        Server->Start();
        Server->Run();

        delete Server;
        delete Tool;

With kind regards