Table of Contents

Attributes

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.

Documentation

Start here Use when
Getting started You want a plain class exposed as a running server quickly.
User guide You want task-oriented chapters grouped by feature area.
API reference You want exact class, property, method, and event contracts.
Release notes You want the version history for this component.

Key classes

Class Role
TTMSMCPCustomAttribute Base class of every MCP attribute. Each attribute also publishes an interface, which is how the server recognises it.
TTMSMCPToolAttribute The marker that promotes a method to a tool. Nothing is generated without it.
TTMSMCPNameAttribute Sets the protocol name of a tool, a resource, a prompt, or a single parameter.
TTMSMCPDescriptionAttribute Sets the description a client shows the model — for the method or for one parameter.
TTMSMCPOptionalAttribute Drops a parameter from the required set and supplies the value used when a client omits it.
TTMSMCPAttributedServer The server that reflects over registered targets and builds tools, resources, and prompts from them.
TTMSMCPTargets The collection of classes and objects the server reflects over.
TTMSMCPTarget One registered class or instance, with its ownership flag.
TTMSMCPServerFactory Creates a fully populated attributed server from a single class or instance.
TTMSMCPRttiTools The tool collection an attributed server uses; its items know which method they invoke.
ITMSMCPServerAware 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.

API map

Role Types
Attribute base and interfaces TTMSMCPCustomAttribute, TTMSMCPCustomValueAttribute, TTMSMCPCustomTypeAttribute, ITMSMCPCustomAttribute, ITMSMCPCustomValueAttribute
Surface markers TTMSMCPToolAttribute, TTMSMCPResourceAttribute, TTMSMCPPromptAttribute
Identity and wording TTMSMCPNameAttribute, TTMSMCPTitleAttribute, TTMSMCPDescriptionAttribute
Behaviour hints TTMSMCPReadOnlyAttribute, TTMSMCPDestructiveAttribute, TTMSMCPIdempotentAttribute, TTMSMCPOpenworldAttribute
Schema types TTMSMCPStringAttribute, TTMSMCPIntegerAttribute, TTMSMCPFloatAttribute, TTMSMCPBooleanAttribute
Parameter control TTMSMCPOptionalAttribute, TTMSMCPCompletionAttribute
Presentation and results TTMSMCPIconAttribute, TTMSMCPOutputSchemaAttribute, TTMSMCPTaskSupportAttribute, TTMSMCPAttrTaskSupport
Resource metadata TTMSMCPURIAttribute, TTMSMCPURITemplateAttribute, TTMSMCPMimeTypeAttribute
Generated server TTMSMCPAttributedServer, TTMSMCPServerFactory, ITMSMCPServerAware
Generated targets and tools TTMSMCPTargets, TTMSMCPTarget, TTMSMCPRttiTools, TTMSMCPRttiTool, TTMSMCPRttiToolProperty

Guides

Guide Covers
Declaring tools with attributes The tool marker, naming, descriptions, behaviour hints, titles and icons, return types, output schemas, and task support.
Parameters and schema How parameters become input properties, type inference and overrides, optional parameters with defaults, value coercion, and argument errors.
Hosting attributed servers Targets, class versus instance registration, ownership, the server factory, re-registration, server awareness, and the resource and prompt attributes.

See Also