by GDKsoftware
Native Delphi Server implementation of the Model Context Protocol (MCP)
# Add to your Claude Code skills
git clone https://github.com/GDKsoftware/Delphi-MCP-ServerGuides for using mcp servers skills like Delphi-MCP-Server.
A Model Context Protocol (MCP) server implementation in Delphi, designed to integrate with Claude Code, Codex, and other MCP-compatible clients for AI-powered Delphi development workflows.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars
git clone https://github.com/GDKsoftware/delphi-mcp-server.git
cd delphi-mcp-server
build.bat
Or specify configuration and platform:
build.bat Debug Win32
build.bat Release Win64
Prerequisites:
From the batch file:
build.bat Release Linux64
Or from RAD Studio IDE:
The server supports two transport modes:
Start the server without arguments for HTTP transport with Server-Sent Events (SSE):
Win32\Debug\MCPServer.exe
The server will listen on http://localhost:3000/mcp by default (configurable via settings.ini).
Use HTTP transport for:
Start the server with --stdio flag for stdin/stdout communication:
Win32\Debug\MCPServer.exe --stdio
The server will:
Use STDIO transport for:
Supported flag variants: --stdio, -stdio, /stdio
The Delphi MCP Server is designed to be used both as a standalone application and as a library for your own MCP server implementations. This section covers how to integrate it into your existing Delphi projects.
# Add MCPServer as a submodule to your project
git submodule add https://github.com/GDKsoftware/delphi-mcp-server.git lib/mcpserver
git submodule update --init --recursive
Copy the src folder from MCPServer into your project and add the units to your uses clauses.
Search Paths: Add the MCPServer source directories to your project search path:
lib\mcpserver\src\Corelib\mcpserver\src\Managerslib\mcpserver\src\Protocollib\mcpserver\src\Serverlib\mcpserver\src\Toolslib\mcpserver\src\ResourcesRequired Units: Include these core units in your project:
MCPServer.Types,
MCPServer.Settings,
MCPServer.Registration,
MCPServer.ManagerRegistry,
MCPServer.IdHTTPServer, // For HTTP transport
MCPServer.StdioTransport, // For STDIO transport
MCPServer.JsonRpcProcessor // Shared JSON-RPC processing
Once you have the project setup complete, the simplest way to add MCP capabilities to your application:
program YourMCPServer;
{$APPTYPE CONSOLE}
uses
System.SysUtils,
MCPServer.Types in 'lib\mcpserver\src\Protocol\MCPServer.Types.pas',
MCPServer.IdHTTPServer in 'lib\mcpserver\src\Server\MCPServer.IdHTTPServer.pas',
MCPServer.Settings in 'lib\mcpserver\src\Core\MCPServer.Settings.pas',
MCPServer.ManagerRegistry in 'lib\mcpserver\src\Core\MCPServer.ManagerRegistry.pas',
MCPServer.CoreManager in 'lib\mcpserver\src\Managers\MCPServer.CoreManager.pas',
MCPServer.ToolsManager in 'lib\mcpserver\src\Managers\MCPServer.ToolsManager.pas',
MCPServer.ResourcesManager in 'lib\mcpserver\src\Managers\MCPServer.ResourcesManager.pas';
var
Server: TMCPIdHTTPServer;
Settings: TMCPSettings;
ManagerRegistry: IMCPManagerRegistry;
begin
Settings := TMCPSettings.Create;
try
ManagerRegistry := TMCPManagerRegistry.Create;
ManagerRegistry.RegisterManager(TMCPCoreManager.Create(Settings));
ManagerRegistry.RegisterManager(TMCPToolsManager.Create);
ManagerRegistry.RegisterManager(TMCPResourcesManager.Create);
Server := TMCPIdHTTPServer.Create(nil);
try
Server.Settings := Settings;
Server.ManagerRegistry := ManagerRegistry;
Server.Start;
Writeln('MCP Server running on port ', Settings.Port);
Readln; // Keep running
Server.Stop;
finally
Server.Free;
end;
finally
Settings.Free;
end;
end.
unit YourProject.Tool.Custom;
interface
uses
MCPServer.Tool.Base,
MCPServer.Types,
MCPServer.Registration;
type
TCustomToolParams = class
private
FInput: string;
FCount: Integer;
public
[SchemaDescription('Text input to process')]
property Input: string read FInput write FInput;
[Optional]
[SchemaDescription('Number of times to repeat (default: 1)')]
property Count: Integer read FCount write FCount;
end;
TCustomTool = class(TMCPToolBase<TCustomToolParams>)
protected
function ExecuteWithParams(const AParams: TCustomToolParams): string; override;
public
constructor Create; override;
end;
implementation
constructor TCustomTool.Create;
begin
inherited;
FName := 'custom_tool';
FDescription := 'A custom tool that processes input';
end;
function TCustomTool.ExecuteWithParams(const AParams: TCustomToolParams): string;
var
I: Integer;
Output: string;
begin
Output := '';
for I := 1 to AParams.Count do
Output := Output + AParams.Input + #13#10;
Result := 'Processed: ' + Output;
end;
initialization
TMCPRegistry.RegisterTool('custom_tool',
function: IMCPTool
begin
Result := TCustomTool.Create;
end
);
end.
unit YourProject.Resource.Custom;
interface
uses
System.SysUtils,
MCPServer.Resource.Base,
MCPServer.Registration;
type
TCustomData = class
private
FMessage: string;
FTimestamp: TDateTime;
public
property Message: string read FMessage write FMessage;
property Timestamp: TDateTime read FTimestamp write FTimestamp;
end;
TCustomResource = class(TMCPResourceBase<TCustomData>)
protected
function GetResourceData: TCustomData; override;
public
constructor Create; override;
end;
implementation
constructor TCustomResource.Create;
begin
inherited;
FURI := 'custom://data';
FName := 'Custom Data';
FDescription := 'Custom resource data';
FMimeType := 'application/json';
end;
function TCustomResource.GetResourceData: TCustomData;
begin
Result := TCustomData.Create;
Result.Message := 'Hello from custom resource';
Result.Timestamp := Now;
end;
initialization
TMCPRegistry.RegisterResource('custom://data',
function: IMCPResource
begin
Result := TCustomResource.Create;
end
);
end.
Configure using the Streamable HTTP transport:
# Basic configuration
claude mcp add --transport http delphi-mcp-server http://localhost:3000/mcp
# With authentication (if configured)
claude mcp add --transport http delphi-mcp-server http://localhost:3000/mcp --header "Authorization: Bearer your-token"
Make sure the server is running before connecting Claude Code.
Configure Codex to use the STDIO transport. Edit your Codex configuration file (~/.codex/config.toml):
[mcp_servers.delphi-mcp-server]
command = 'C:\path\to\MCPServer.exe'
args = ["--stdio"]
Or on Linux/macOS:
[mcp_servers.delphi-mcp-server]
command = '/path/to/MCPServer'
args = ["--stdio"]
Important: The server must be compiled and the executable path must be absolute.
After configuration:
/mcp command to verify the server is connectedThe server supports HTTPS connections when configured with SSL certificates:
# Genera