home / mcp / delphi build mcp server
Provides an MCP server that compiles Delphi projects via AI agents and returns structured errors.
Configuration
View docs{
"mcpServers": {
"basti-fantasti-delphi-build-mcp-server": {
"command": "uv",
"args": [
"run",
"--directory",
"X:\\path\\to\\delphi-build-mcp-server",
"python",
"main.py"
],
"env": {
"DELPHI_CONFIG": "X:\\path\\to\\delphi_config.toml"
}
}
}
}This MCP server lets AI coding agents programmatically compile Delphi projects. It reads project configurations, builds with the Delphi compiler, and returns structured error information, enabling automated code generation and validation workflows across Win32 and Win64 targets.
You integrate this server with an MCP client to compile Delphi projects from AI prompts. The server loads a delphi_config.toml configuration, determines the active build settings from your .dproj/.dpr files, constructs the compiler command, runs the Delphi toolchain, and returns only errors (warnings and hints are filtered out) in a structured format.
To run locally, you can start the MCP interface as a stdio server using the provided runtime command, or you can run it via a Python interpreter if you prefer a virtual environment. The server supports command lines longer than 8000 characters by handling response files automatically, and it can parse English and German compiler output.
Typical usage flow: - Provide the path to your Delphi project file (.dproj or .dpr). - The server loads Delphi installation paths and library search paths from the configuration. - It parses the project file to identify the active configuration (Debug/Release) and compiler flags. - It builds a complete compiler command, including search paths and defines, and executes the appropriate dcc8/dcc32/dcc64 compiler depending on your target. - The server parses the compiler output, extracts errors, and returns a structured result with the path to the produced executable if successful.
Prerequisites you need to have before installing the server include Python 3.10+ and a Delphi toolchain that supports Delphi 11, 12, or 13.
Step 1. Install UV if you haven’t already. Run one of the following commands:
- On Windows: `powershell -c "irm https://astral.sh/uv/install.ps1 | iex"`
- On macOS or Linux: `curl -LsSf https://astral.sh/uv/install.sh | sh`
- Or install via Python: `pip install uvStep 2. Synchronize the server repository with UV (if you’re using a local clone):
- cd delphi-build-mcp-server
- uv sync
Step 3. Generate configuration from a build log or a Delphi IDE build. If you have a build log build.log, generate a TOML config using:
``
uv run python -m src.config_generator build.log
``
Step 4. If you prefer the Python API, you can generate the config programmatically:
``
from src.config_generator import ConfigGenerator
from pathlib import Path
generator = ConfigGenerator()
result = generator.generate_from_build_log(
build_log_path=Path("build.log"),
output_path=Path("delphi_config.toml")
)
print(result.message)
``
The MCP server can be started in a local environment using one of the following stdio configurations. Each configuration runs the main server script via a chosen runtime and provides the path to the TOML config through an environment variable named DELPHI_CONFIG.
{
"mcpServers": {
"delphi_build": {
"type": "stdio",
"name": "delphi_build",
"command": "uv",
"args": [
"run",
"--directory",
"X:\\path\\to\\delphi-build-mcp-server",
"python",
"main.py"
],
"env": {
"DELPHI_CONFIG": "X:\\path\\to\\delphi_config.toml"
}
}
}
}Alternatively, you can run the Python-based setup directly with a Python interpreter and the main script, if you prefer a virtual environment. The environment variable remains DELPHI_CONFIG to point to the generated configuration.
{
"mcpServers": {
"delphi_build": {
"type": "stdio",
"name": "delphi_build",
"command": "X:\\path\\to\\delphi-build-mcp-server\\.venv\\Scripts\\python.exe",
"args": ["X:\\path\\to\\delphi-build-mcp-server\\main.py"],
"env": {
"DELPHI_CONFIG": "X:\\path\\to\\delphi_config.toml"
}
}
}
}If you encounter a message like “Configuration file not found,” generate it from a build log as shown above. If the compiler reports unit not found, regenerate the configuration from a fresh IDE build log that includes all dependencies. If the compiler cannot be found, verify that delphi.root_path in your delphi_config.toml points to your Delphi installation.
This server automatically handles long command lines (80+ library paths) by using response files and can parse both English and German compiler output, returning only error entries in the results.
The server exposes programmable tools for Delphi project compilation and configuration generation. Key functions include compiling a Delphi project and generating a config from a build log.
Compile a project with the following Python snippet, then inspect the result for the path to the produced executable or the list of errors.
from src.compiler import DelphiCompiler
from pathlib import Path
compiler = DelphiCompiler()
result = compiler.compile_project(
project_path=Path("X:/MyProject/MyApp.dproj")
)
if result.success:
print(f"Compilation successful: {result.output_executable}")
else:
print(f"Compilation failed with {len(result.errors)} errors:")
for error in result.errors:
print(f" {error.file}({error.line},{error.column}): {error.message}")Generate a configuration from a build log using the Python API and inspect detected Delphi version, platform, and path statistics.
from src.config_generator import ConfigGenerator
from pathlib import Path
generator = ConfigGenerator(use_env_vars=True)
result = generator.generate_from_build_log(
build_log_path=Path("build.log"),
output_path=Path("delphi_config.toml")
)
print(f"{result.message}")
print(f" Detected: Delphi {result.detected_info.delphi_version}")
print(f" Platform: {result.detected_info.platform}")
print(f" Paths found: {result.statistics['unique_paths']}")Compile a Delphi project and return a structured result including success, errors (only errors), compilation time, output executable, and statistics.
Create a delphi_config.toml from an IDE build log, returning the path to the generated config and detected Delphi info.