Delphi MCP Server
Build Model Context Protocol (MCP) servers in Delphi. Expose tools, resources, and prompts to AI applications.
Build Model Context Protocol (MCP) servers in Delphi. Expose tools, resources, and prompts to AI applications.
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.
TsgcWSAPIServer_MCP
Model Context Protocol server, spec 2026-07-28 with 2025-11-25 backward compatibility
Windows, macOS, Linux, iOS, Android
Enterprise / sgcAI
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;
5 published properties, 9 methods, 12 events — pulled from the component reference.
Methods: KeepAlive.
Events: OnMCPHTTPRequest, OnMCPHTTPResponse.
Published properties: MCPOptions, EndpointOptions, TransportOptions.
Published properties: Version.
Properties: Server.
Methods: RequestRootsList, RequestSamplingCreateMessage, RequestElicitationCreate.
Stateless requests with per-request _meta, server/discover, Mcp-Method / Mcp-Name / Mcp-Param header validation and cache hints (MCPOptions.Cache). Clients on 2025-11-25 keep using initialize and sessions on the same server.
subscriptions/listen streams list changes and resource updates. Options: MCPOptions.Subscriptions. Method: CloseSubscriptions.
Ask the client for elicitation (form or URL), sampling or roots from a tool with aResponse.InputRequired. The requestState is HMAC signed (MCPOptions.MRTR).
io.modelcontextprotocol/tasks for long running tools. Method: CreateTask. Options: MCPOptions.Tasks.
Authoritative sources for the protocols this component implements.
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. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |
TsgcWSAPIServer_MCP component, set MCPOptions.HttpOptions.Port and MCPOptions.ServerInfo, hook the OnMCPRequest* handlers, then set Active := True. It hosts a JSON-RPC endpoint on top of a sgcWebSockets HTTP server.
TransportOptions and EndpointOptions published properties.
OnMCPRequestTool for tool calls, OnMCPRequestPrompt for prompts and OnMCPRequestResource for resources. You can also push updates to every connected session, for example with SendNotificationToolsListChanged.
RequestRootsList, RequestSamplingCreateMessage and RequestElicitationCreate, so the server can ask the connected MCP client for roots, sampling completions or user input. On MCP 2026-07-28 the same questions travel as Multi Round-Trip Requests: the tool handler fills aResponse.InputRequired, for example with AddElicitation, and reads the answers on the retried call with InputResponse.
server/discover, subscriptions/listen, Multi Round-Trip Requests and the Tasks extension) and keeps full backward compatibility with 2025-11-25 clients that use initialize and sessions. Both eras are served by the same component, the era is detected on every request. Available in sgcWebSockets 2026.10.0 for Delphi 7 to Delphi 13 and in the .NET package.