Table of Contents

MCP Server

TTMSMCPServer turns a Delphi application into a Model Context Protocol server: a JSON-RPC 2.0 endpoint that advertises what the application can do and lets an AI agent call it. The server owns three collections — tools it can execute, resources it can read, and prompts it can supply — and handles the rest of the protocol around them: capability negotiation across four protocol versions, per-session state, change notifications, pagination, sampling, elicitation, long-running tasks, logging, completions, and an extensions framework.

Documentation

Start here Use when
Getting started You want a running server with one tool.
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
TTMSMCPServer The server component. Drop it on a form or create it in code.
TTMSMCPCustomServer Base class carrying the protocol implementation.
TTMSMCPServerBuilder Fluent builder that configures and returns a server.
TTMSMCPSessionState One connected client's session: id, protocol version, own resources and prompts, subscriptions, and user data.
TTMSMCPTask A long-running unit of work with status, result, TTL, and poll interval.
TTMSMCPTaskRegistry The server's live set of tasks.
TTMSMCPElicitRequest A schema-described question the server asks the client mid-request.
TTMSMCPSamplingRequest A request for the client to run a model completion on the server's behalf.
TTMSMCPAttributedServer A server whose surface is generated from RTTI attributes.
TTMSMCPCustomComponent Shared base for the product's components.

Minimal example

procedure TForm1.FormCreate(Sender: TObject);
begin
  Server := TTMSMCPServer.Create(Self);
  Server.ServerName := 'InventoryServer';
  Server.ServerVersion := '1.0.0';
  Server.ServerDescription := 'Read-only access to the warehouse inventory';

  Server.Tools.RegisterTool('stock_level',
    'Returns the number of units on hand for a product',
    function(const Args: array of TValue): TValue
    begin
      Result := StockLevel(Args[0].AsString);
    end,
    ptInteger);

  { With no Transport assigned the server uses STDIO. }
  Server.Start;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Server.Stop;
end;

API map

Role Types
Server TTMSMCPServer, TTMSMCPCustomServer, TTMSMCPServerBuilder
What it exposes TTMSMCPTools, TTMSMCPResources, TTMSMCPPrompts
Sessions TTMSMCPSessionState, TTMSMCPSessionEvent
Tasks TTMSMCPTask, TTMSMCPTaskRegistry, TTMSMCPTaskStatus, TTMSMCPTaskCreateEvent, TTMSMCPTaskExecuteEvent, TTMSMCPTaskCancelEvent
Elicitation TTMSMCPElicitRequest, TTMSMCPElicitSchema, TTMSMCPElicitField, TTMSMCPElicitResult, TTMSMCPElicitFieldType
Sampling TTMSMCPSamplingRequest, TTMSMCPSamplingResult, TTMSMCPSamplingMessage, TTMSMCPSamplingModelPreferences
Logging and completions TTMSMCPLogLevel, TTMSMCPLogLevelChangedEvent, TTMSMCPCompletionEvent
Protocol TMCPProtocolVersion, TMCPCapabilityProfile, TTMSMCPRoot, TTMSMCPRootsChangedEvent, TTMSMCPCursor, TTMSMCPErrorCode
Execution hooks TTMSMCPOnBeforeExecuteToolEvent, TTMSMCPAfterExecuteToolEvent, TTMSMCPToolListEvent, TTMSMCPResourceListEvent, TTMSMCPPromptsListEvent

Guides

Guide Covers
Configuring the server Identity, instructions, the builder, capability flags, change notifications, pagination, logging, completions, and error codes.
Sessions and state Per-session state, values, user data, session-only resources and prompts, subscriptions, and protocol negotiation.
Tasks and elicitation Long-running tasks, progress and cancellation, asking the client a question, sampling, and client roots.

See Also