A Model Context Protocol (MCP) server implementation in Delphi, designed to integrate with Claude Code and other MCP-compatible clients for AI-powered Delphi development workflows.
- Features
- Requirements
- Installation
- Using as a Library
- Integration with Claude Code
- Testing with MCP Inspector
- Available Example Tools
- Available Example Resources
- Configuration
- License
- Contributing
- About GDK Software
- Support
- Full MCP Protocol Support: Implements the Model Context Protocol specification for seamless AI integration
- Tool System: Extensible tool system with RTTI-based discovery and execution
- Resource Management: Modular resource system supporting various content types
- JSON-RPC 2.0: Standards-compliant JSON-RPC implementation
- Security: Built-in security features including CORS configuration
- High Performance: Native implementation using Indy HTTP Server
- Optional Parameters: Support for optional tool parameters using custom attributes
- Cross-Platform: Supports Windows (Win32/Win64) and Linux (x64)
- Delphi 12 Athens or later
- Windows (Win32/Win64) or Linux (x64)
- No external dependencies (all required libraries included)
- Clone the repository:
git clone https://github.com/GDKsoftware/delphi-mcp-server.git
cd delphi-mcp-server
- Build the project:
build.bat
Or specify configuration and platform:
build.bat Debug Win32
build.bat Release Win64
Prerequisites:
- Delphi Enterprise with Linux platform support
- PAServer running on Linux target machine
- Linux SDK configured in RAD Studio
From the batch file:
build.bat Release Linux64
Or from RAD Studio IDE:
- Open MCPServer.dproj
- Select Linux64 platform
- Build
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\Core
lib\mcpserver\src\Managers
lib\mcpserver\src\Protocol
lib\mcpserver\src\Server
lib\mcpserver\src\Tools
lib\mcpserver\src\Resources
-
Required Units: Include these core units in your project:
MCPServer.Types, MCPServer.Settings, MCPServer.Registration, MCPServer.ManagerRegistry, MCPServer.IdHTTPServer
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
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.
The easiest way to test and debug your MCP server is using the official MCP Inspector:
-
Start the server:
# Build and run the server build.bat Win32\Debug\MCPServer.exe
-
Run MCP Inspector:
# Install and run the MCP Inspector npx @modelcontextprotocol/inspector
-
Connect to your server:
- Transport: HTTP
- URL:
http://localhost:3000/mcp
- Click Connect
-
Test functionality:
- Browse available tools and resources
- Execute tools like
echo
,get_time
,calculate
- View resources like
project://info
,server://status
- Monitor request/response JSON-RPC messages
The Inspector provides a web interface to interact with your MCP server, making it perfect for development and debugging.
- echo: Echo a message back to the user
- get_time: Get the current server time
- list_files: List files in a directory
- calculate: Perform basic arithmetic calculations
The server provides four essential resources accessible via URIs:
- project://info - Project information (JSON metadata with collections)
- project://readme - This README file (markdown content)
- logs://recent - Recent log entries from all categories (with thread safety)
- server://status - Current server status and health information
The server supports configuration through settings.ini
files. A default settings.ini.example
is provided in the repository.
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions! Here's how to help:
- Use GitHub Issues for bugs and feature requests
- Include Delphi version, platform, and reproduction steps
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature
- Follow existing code style (inline vars, named constants)
- Test your changes
- Submit a pull request
- Requires Delphi 12+
- Open
MCPServer.dproj
or build withbuild.bat
- Test with
npx @modelcontextprotocol/inspector
or Claude Code or similar
GDK Software is a software company specializing in Delphi development, upgrades, and migrations. We provide Delphi development, upgrades, maintenance, and modernization of application services. GDK Software also offers consulting and training related to Delphi and low-code development with Codolex. We have a global presence with offices in the Netherlands, UK, USA, and Brazil.
- Create an issue on GitHub
- Visit our website at www.gdksoftware.com
- Contact us for commercial support