Table of Contents

Getting started with MCP Server

This page covers the shortest path to a running MCP server: what you need, how to give the server an identity, how to expose one tool, and how a client connects. For capabilities, sessions, and long-running work see the user guide.

Prerequisites

  • Delphi 11 Alexandria or newer (or C++Builder) with TMS AI Studio installed.
  • A VCL or FMX application. The server is non-visual, so a console or service application works too.
  • An MCP client to talk to. Any client that speaks the protocol will do; a desktop AI assistant configured to launch your executable over STDIO is the quickest way to see it work.

TTMSMCPServer and the transports it uses are registered for Windows targets only — the component declares TMSPlatformsWinOnly, so it does not appear on the palette for a macOS, Linux, iOS, or Android target, and the server side of the protocol is not supported there. The MCP client and the cloud AI components are not restricted this way; only hosting a server is.

Add TMS.MCP.Server to your uses clause. You will usually also want TMS.MCP.Tools and TMS.MCP.Helpers for the tool types.

Create the server

Drop a TTMSMCPServer on a form, or create it in code. Give it a name, a version, and at least one thing to do:

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;

ServerName and ServerVersion are what the client shows the user and reports to the model, so use the product name rather than the unit name. ServerDescription is optional but worth setting — it is the one-line answer to "what is this server for".

Choose a transport

With no Transport assigned the server uses STDIO, which is what a desktop AI assistant expects when it launches your executable directly. That makes STDIO the right default for a first test. Named Pipe, SSE, and Streamable HTTP are available when the server is a long-running process a client connects to rather than launches — see MCP Transports.

Start and stop

Start begins listening on the transport; Stop shuts it down. Call Stop before the form is destroyed so in-flight sessions close cleanly.

What the client sees

On connect, the client and server negotiate a protocol version and exchange capabilities. The client then asks for the tool list and shows your tool's name and description to the model. If the model decides to call it, the server runs your method and returns the result. Nothing else is required to make an application reachable by an agent.

See also