JavierusTk/MCPServer
If you are the rightful owner of MCPServer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Server is a Delphi-based server designed for integration with Claude Code, providing tools for debugging and message capture.
MCP Server
Model Context Protocol (MCP) server for integration with Claude Code.
Description
This Delphi-based MCP server provides:
- Integration with Claude Code via Model Context Protocol
- Basic "Hello World" demonstration tools
- Advanced Windows OutputDebugString capture and analysis tools
- Reusable non-visual components for building MCP servers
Built using the Delphi-MCP-Server framework.
Project Structure
/mnt/w/MCPserver/
βββ MCPServerCore.dproj # RTL-only core package
βββ MCPServerDesign.dproj # Package with visual components
βββ MCPServerDesign.VCL.dpk # VCL package for IDE
βββ MCPServerDesign.FMX.dpk # FMX package for IDE
βββ MCPServer.Engine.pas # Main server engine
βββ MCPServer.Adapter.pas # Adapter for non-visual components
βββ MCPServer.Config.pas # Configuration with builder pattern
βββ MCPServer.Register.pas # Component registration in IDE
βββ README.md # This documentation
βββ README-ES.md # Spanish documentation
βββ CLAUDE.md # Guide for Claude Code
βββ settings.ini # Server configuration
βββ Examples/ # Examples and tools
βββ CyberMaxHelloMCP.dpr/dproj # Basic standalone example
βββ ExampleMCPEngine.dpr/dproj # Example with TMCPEngine
βββ ExampleVCLApp.dpr/dproj # VCL application example
βββ Tools/ # MCP tools
βββ MCPServer.Tool.HelloCyberMax.pas
βββ MCPServer.Tool.CyberEcho.pas
βββ MCPServer.Tool.CyberTime.pas
βββ MCPServer.Tool.StartDebugCapture.pas
βββ MCPServer.Tool.StopDebugCapture.pas
βββ MCPServer.Tool.GetDebugMessages.pas
βββ MCPServer.Tool.GetProcessSummary.pas
βββ MCPServer.Tool.GetCaptureStatus.pas
βββ MCPServer.Tool.PauseResumeCapture.pas
βββ MCPServer.DebugCapture.Core.pas
βββ MCPServer.DebugCapture.Types.pas
Available Tools
Basic Tools
1. hello_cybermax
Returns a welcome message from the MCP server.
Parameters: None
Example response:
Β‘Hola desde CyberMAX MCP Server!
Server Version: 1.0.0
MCP Protocol: 2024-11-05
Ready to assist!
2. cyber_echo
Echoes back the sent message, optionally in uppercase.
Parameters:
message
(string, required): The message to echo backuppercase
(boolean, optional): If true, returns the message in uppercase
3. cyber_time
Returns the current system time with customizable formatting.
Parameters:
format
(string, optional): Date/time formatincludemilliseconds
(boolean, optional): Include millisecondstimezone
(string, optional): Timezone offset
Debug Capture Tools
Note: No administrator privileges required! The debug capture uses session-local objects to capture OutputDebugString messages from user applications in your Windows session.
4. start_debug_capture
Starts a Windows OutputDebugString message capture session.
Parameters:
sessionname
(string, optional): Descriptive session nameprocessfilter
(string, optional): Filter by process namemessagefilter
(string, optional): Filter messages containing this textmaxmessages
(integer, optional): Maximum message limit (default: 10000)includesystem
(boolean, optional): Include system processes
Returns: Session ID to use with other tools
5. stop_debug_capture
Stops an active capture session.
Parameters:
sessionid
(string, required): ID of the session to stop
6. get_debug_messages
Retrieves captured messages with optional filters.
Parameters:
sessionid
(string, required): Session IDlimit
(integer, optional): Maximum messages to return (default: 100)offset
(integer, optional): Offset for paginationsincetimestamp
(string, optional): Filter from this date/timeprocessid
(integer, optional): Filter by PIDprocessname
(string, optional): Filter by process namemessagecontains
(string, optional): Filter messages containing textmessageregex
(string, optional): Filter with regular expression
7. get_process_summary
Gets statistics of processes that have emitted messages.
Parameters:
sessionid
(string, required): Session ID
8. get_capture_status
Gets capture session status information.
Parameters:
sessionid
(string, required): Session ID
9. pause_resume_capture
Pauses or resumes message capture.
Parameters:
sessionid
(string, required): Session IDpause
(boolean, required): true to pause, false to resume
Server Configuration
settings.ini
[Server]
Port=3001
Host=localhost
Transport=http
MaxConnections=10
AllowedOrigins=http://localhost,http://127.0.0.1,https://localhost,https://127.0.0.1
[Logging]
LogLevel=INFO
LogFile=mcp_server.log
ConsoleLog=True
[MCP]
ProtocolVersion=2024-11-05
ServerName=MCP Server
ServerVersion=1.0.0
Important note: Default port is 3001 (changed from 3000 to avoid conflicts).
Compilation
Prerequisites
- RAD Studio 12 (Delphi 29.0)
- Base Delphi-MCP-Server repository cloned at
/mnt/w/Delphi-MCP-Server
- TaurusTLS_RT in runtime packages
Building the Projects
Option 1: Standalone Example (CyberMaxHelloMCP)
Compilar Examples/CyberMaxHelloMCP.dproj
Option 2: Example with TMCPEngine
Compilar Examples/ExampleMCPEngine.dproj
Option 3: VCL Application
Compilar Examples/ExampleVCLApp.dproj
Building the Packages (for component development)
Compilar MCPServerCore.dproj # RTL-only package
Compilar MCPServerDesign.dproj # Package with visual components
Note: The compiler-agent requires the .dproj file
Running the Server
Run CyberMaxHelloMCP (basic example)
cd /mnt/w/MCPserver/Examples
./CyberMaxHelloMCP.exe
Run ExampleMCPEngine (with advanced configuration)
cd /mnt/w/MCPserver/Examples
./ExampleMCPEngine.exe
The server will display:
========================================
CyberMAX MCP Server - Hello World v1.0
========================================
Server started successfully!
Available tools:
Basic Tools:
- hello_cybermax : Get greeting and CyberMAX info
- cyber_echo : Echo back your message
- cyber_time : Get current system time
Debug Capture Tools:
- start_debug_capture : Start capturing OutputDebugString
- stop_debug_capture : Stop capture session
- get_debug_messages : Retrieve captured messages
- get_process_summary : Get process statistics
- get_capture_status : Get session information
- pause_resume_capture : Pause/resume capture
Press CTRL+C to stop...
Configuring Claude Code
1. Determine Windows System IP
From WSL, run:
ip route | grep default | awk '{print $3}'
# Or verify with: hostname -I
In this case, the IP is: 192.168.0.89
2. Configure Claude Code
The MCP server uses HTTP transport with the /mcp
endpoint. Claude Code requires command-line configuration.
Recommended method - mcp add
command:
claude mcp add cybermax-hello http://192.168.0.89:3001/mcp --scope user -t http
Important parameters:
cybermax-hello
: MCP server namehttp://192.168.0.89:3001/mcp
: Complete URL with endpoint--scope user
: Configuration scope (user, project, or local)-t http
: HTTP transport type (required for remote servers)
Alternative method - Interactive /config
command:
# Within Claude Code, use:
/config
# Then manually add the server
Important notes:
- The
--mcp-config
flag has a known bug in version v1.0.73 and doesn't work correctly - For remote HTTP servers, ALWAYS specify
-t http
- Must use the
/mcp
endpoint (not just IP and port) - Correct format is:
http://IP:PORT/mcp
3. Verify Connection
Once configured, tools will appear with the prefix mcp__cybermax-hello__
:
mcp__cybermax-hello__hello_cybermax
mcp__cybermax-hello__cyber_echo
mcp__cybermax-hello__cyber_time
To verify the server is available:
# List configured MCP servers
claude mcp list
# Or within Claude Code
/mcp
Technical Architecture
Main Components
TMCPEngine
Main non-visual component that encapsulates all MCP server functionality:
- Automatic server lifecycle management
- Configuration via published properties
- Events for logging and control
- Auto-registration of tools
- CORS support
TMCPAdapter
Adapter component allowing TMCPEngine use in VCL/FMX applications:
- Published properties for design-time configuration
- Events visible in Object Inspector
- Delphi IDE integration
TMCPConfig
Configuration class with builder pattern:
Config := TMCPConfig.Create
.WithPort(3001)
.WithHost('localhost')
.WithServerName('MCP Server')
.WithCORS(True);
Tool Pattern
Each tool implements:
- Parameter class with RTTI attributes for schema generation
- Tool class extending
TMCPToolBase<TParams>
- Automatic registration in initialization section
Error Handling
The server implements robust error handling:
- Parameter validation before processing
- Explicit initialization of optional values in constructors
- Direct property usage without unnecessary complexity
Correct example in cyber_echo:
// Initialization in constructor
constructor TCyberEchoParams.Create;
begin
inherited;
FMessage := '';
FUpperCase := False; // Explicit even though Delphi initializes to False
end;
// Direct and simple property usage
if Params.UpperCase then
ProcessedMessage := System.SysUtils.UpperCase(Params.Message)
else
ProcessedMessage := Params.Message;
Important note:
- Don't use try-except for reading simple properties
- Don't copy property values to local variables unnecessarily
- Delphi automatically initializes: BooleanβFalse, Integerβ0, Stringβ''
Use Cases
Windows Application Debugging
Debug capture tools enable:
- Real-time monitoring of OutputDebugString messages
- Process or message content filtering
- Non-invasive application behavior analysis
- Debugging intermittent production issues
Developing New Tools
To add a new tool:
- Create parameter class with schema attributes
- Implement tool extending
TMCPToolBase<TParams>
- Register in initialization section
- Tool is automatically discovered via RTTI
Minimal example:
type
TMyParams = class
[SchemaDescription('Parameter description')]
property MyParam: string read FMyParam write FMyParam;
end;
TMyTool = class(TMCPToolBase<TMyParams>)
protected
function ExecuteWithParams(const Params: TMyParams): string; override;
public
constructor Create; override;
end;
initialization
TMCPRegistry.RegisterTool('my_tool', function: IMCPTool
begin Result := TMyTool.Create; end);
Troubleshooting
Port in Use
If port 3001 is in use:
- Change in
settings.ini
- Update configuration in Claude Code
Access Violation
If Access Violation errors appear:
- Verify initialization of optional parameters
- Add constructors with default values
- Implement defensive property handling
Server Not Visible in Claude Code
- Verify it uses HTTP transport (not stdio)
- Confirm
/mcp
endpoint - Use Windows system IP, not localhost from WSL
- Check Windows firewall
Hung Process
# From WSL
taskkill.exe /IM CyberMaxHelloMCP.exe /F
# Or find and kill process
ps aux | grep CyberMax
kill -9 [PID]
Logs and Debugging
Server logs show:
- Initialization and configuration
- Each received JSON-RPC request
- Claude Code Session ID
- Sent responses
- Errors and exceptions
Log example:
[2025-09-03 13:17:14.906] [INFO ] Request: {"method":"tools/call","params":{"name":"cyber_echo",...}}
[2025-09-03 13:17:14.906] [INFO ] Session ID from header: {ADB063D4-752F-4795-A98D-0E843FDF2AA4}
[2025-09-03 13:17:14.906] [INFO ] MCP CallTool called for tool: cyber_echo
[2025-09-03 13:17:14.906] [INFO ] Response: {"jsonrpc":"2.0","id":3,"result":{...}}
Technical Notes
- Platform: Windows (debug capture requires Windows APIs)
- Privileges: No admin rights needed for debug capture - uses session-local objects
- Conflict Detection: Automatically detects and reports if DebugView or other debuggers are running
- Encoding: UTF-8 for new files
- Protocol: MCP over JSON-RPC 2.0
- RTTI: Automatic tool discovery via attributes
- Thread-safe: Debug capture in separate thread with full synchronization
- CORS: Configurable for development
Last updated: 2025-09-17 MCP Server v2.0.0