The attribute layer turns an ordinary Delphi class into an MCP server surface. Instead of building a TTMSMCPTool, declaring each input property, and wiring a callback, you mark a method with [TTMSMCPToolAttribute], describe it and its parameters with a handful of metadata attributes, and hand the class to a TTMSMCPAttributedServer. The server reflects over the type with RTTI, derives the tool name, description, behaviour hints, input schema, and return type from the declaration itself, and invokes the method for you when a client calls it. The result is that the documentation a model reads lives next to the code it describes, and cannot drift away from it.
Implement it on a target to receive a reference to the hosting server.
Minimal example
unit CatalogService;
interface
uses
TMS.MCP.Attributes;
type
TCatalogService = class
public
[TTMSMCPToolAttribute]
[TTMSMCPNameAttribute('lookup_price')]
[TTMSMCPDescriptionAttribute('Returns the current unit price of one catalog article')]
[TTMSMCPReadOnlyAttribute]
function LookupPrice(const ASku: string): Double;
[TTMSMCPToolAttribute]
[TTMSMCPNameAttribute('restock')]
[TTMSMCPDescriptionAttribute('Adds units to the stock level of one catalog article')]
procedure Restock(const ASku: string; AUnits: Integer);
end;
implementation
uses
System.SysUtils;
function TCatalogService.LookupPrice(const ASku: string): Double;
begin
Result := CatalogDatabase.PriceOf(ASku);
end;
procedure TCatalogService.Restock(const ASku: string; AUnits: Integer);
begin
if AUnits <= 0 then
raise Exception.Create('AUnits must be greater than zero');
CatalogDatabase.AddStock(ASku, AUnits);
end;
end.