A tool is a callable operation that an MCP client — and through it, a language model — can invoke on your server. Each tool declares a name, a description, and a set of typed input properties, so the model knows both what the tool does and exactly what arguments it accepts. TTMSMCPTool covers the whole surface: simple single-argument callbacks, structured arguments including arrays of objects, behaviour hints that tell a client whether a call is safe to repeat, JSON output schemas, native MCP content items, and opt-in execution as a long-running task.
Generates a JSON schema from a Delphi type, for output schemas and object arguments.
Minimal example
procedure TForm1.RegisterGreetTool;
var
Prop: TTMSMCPToolProperty;
begin
{ Server is a TTMSMCPServer dropped on the form. }
Server.Tools.RegisterTool('greet_user', 'Generates a greeting for a person',
function(const Args: array of TValue): TValue
begin
Result := Format('Hello, %s!', [Args[0].AsString]);
end,
ptString);
{ RegisterTool creates the tool with no declared input properties, so
declare them separately - the client needs them to build the call. }
Prop := Server.Tools.FindByName('greet_user').Properties.Add;
Prop.Name := 'name';
Prop.Description := 'Name of the person to greet';
Prop.PropertyType := ptString;
Prop.Required := True;
end;