MCP Server

Build Model Context Protocol (MCP) servers in Delphi. Expose tools, resources, and prompts to AI applications.

TsgcWSAPIServer_MCP

Expose your own tools, prompts and resources to any MCP-aware LLM client. Hosts a JSON-RPC endpoint with HTTP and HTTP Streamable transports on top of a sgcWebSockets HTTP server.

Component class

TsgcWSAPIServer_MCP

Protocol

Model Context Protocol server

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Enterprise (AI add-on)

Drop the component, set a few properties, go

Attach to an HTTP server, populate ServerInfo, hook the OnMCPRequest* handlers, set Active := True.

uses
  sgcAI_MCP_Server, sgcAI_MCP_Classes;

var
  MCP: TsgcWSAPIServer_MCP;
begin
  MCP := TsgcWSAPIServer_MCP.Create(nil);
  MCP.MCPOptions.HttpOptions.Port   := 8080;
  MCP.MCPOptions.ServerInfo.Name    := 'sgc-mcp-server';
  MCP.MCPOptions.ServerInfo.Title   := 'Weather MCP';
  MCP.MCPOptions.ServerInfo.Version := '1.0.0';

  // Lifecycle + incoming request handlers
  MCP.OnMCPInitialize     := SrvInitialize;
  MCP.OnMCPSessionNew     := SrvSessionNew;
  MCP.OnMCPRequestTool    := SrvCallTool;
  MCP.OnMCPRequestPrompt  := SrvGetPrompt;
  MCP.OnMCPRequestResource := SrvReadResource;

  MCP.Active := True;

  // Push a notification to every connected session
  MCP.SendNotificationToolsListChanged;
end;

What's inside

5 published properties, 9 methods, 12 events — pulled from the component reference.

Lifecycle

Methods: KeepAlive.

HTTP

Events: OnMCPHTTPRequest, OnMCPHTTPResponse.

Configuration

Published properties: MCPOptions, EndpointOptions, TransportOptions.

Diagnostics

Published properties: Version.

Server

Properties: Server.

Server-initiated requests

Methods: RequestRootsList, RequestSamplingCreateMessage, RequestElicitationCreate.

Specifications & references

Authoritative sources for the protocols this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Demo Project — Demos\AI\MCP\Server Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only.
User Manual (PDF) Comprehensive manual covering every component in the library.

Ready to Build an MCP Server?

Download the free trial and start building in minutes.