Token导航 LogoToken导航TokenDH.com
Delphi Build MCP Server logo
开发工具stdio官方级别未说明来源级核验

Delphi Build MCP Server

MCP Server

一个支持AI编程代理(如Claude Code)以编程方式编译Delphi项目的模型上下文协议(MCP)服务器。

工具数

4

提示词数

0

GitHub Stars

6

资源数

0
PythonClaude开发工具ClaudeCline

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Basti-Fantasti

提供方

Basti-Fantasti

最后核验

2026/5/17 20:19

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run python -m src.config_generator build.log

详细介绍

Delphi构建MCP服务器

一个模型上下文协议(MCP)服务器,使Claude Code等AI编码代理能够以编程方式编译Delphi项目。

特性

  • IDE相同的Windows版本:Windows目标(Win32/Win64/Win64x)通过MSBuild编译,向Delphi IDE生成字节相同的输出,包括图标、清单和DPI感知
  • 混合编译:用于Windows目标的MSBuild,用于交叉编译的直接dcc(Linux64/Android/Android64)
  • 最小配置:Windows目标只需要Delphi安装路径——MSBuild从.dproj读取其他所有内容
  • 自动配置:使用多行解析从IDE构建日志生成配置
  • 多配置支持:从多个构建日志生成统一配置(调试/发布×Win32/Win64/Win64x/Linux64)
  • 扩展配置:在不重新生成的情况下,将新平台或库添加到现有配置中
  • 智能编译:读取.dproj文件以获取生成设置和编译器标志
  • 套餐支持:使用正确的输出(.exe/.bpl)编译应用程序(.dpr)和包(.dpk)项目
  • 过滤输出:仅返回错误,过滤掉警告和提示
  • 多语言支持:解析英语和德语编译器输出
  • 响应文件支持:自动处理超过8000个字符的命令行
  • 交叉平台的:支持Win32、Win64、Win64x(LLVM)、Linux64、Android和Android64
  • 环境变量:自动扩展 ${USERNAME} 在路径
  • MCP兼容:与Claude Code、Cline和其他MCP客户合作
  • 网络传输:对远程访问的流式HTTP支持(例如,WSL Ubuntu到Windows主机)
  • WSL互操作:通过stdio、Windows Python或流式HTTP从WSL Ubuntu使用

快速开始

1.安装

# Install UV if you haven't already
# Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
# Or: pip install uv

cd delphi-build-mcp-server
uv venv
uv pip install -e .

2.生成配置

在Delphi IDE中:

  1. 工具>选项>构建>显示编译器进度>“详细”
  2. 构建您的项目
  3. 查看>消息>右键单击>全部复制
  4. 保存到 build.log

然后生成配置:

单一构建日志(简单项目):

# Platform-specific config is generated by default (e.g., delphi_config_win64.toml)
uv run python -m src.config_generator build.log

# Generate generic delphi_config.toml instead
uv run python -m src.config_generator build.log --generic

多个构建日志(多平台项目):

对于针对多个平台(Win32/Win64/Linux64)的项目,为每种配置创建构建日志:

  1. 每个平台/配置组合的内置IDE
  2. 分别保存每个构建日志(例如。, build_debug_win32.log, build_release_linux64.log)
  3. 从所有日志生成配置:
# Separate platform-specific config files (default)
uv run python -m src.multi_config_generator build_win32.log build_win64.log
# Creates: delphi_config_win32.toml, delphi_config_win64.toml

# Custom output directory for platform-specific files
uv run python -m src.multi_config_generator *.log -d ./configs/

# Single unified config instead of separate files
uv run python -m src.multi_config_generator build_win32.log build_win64.log --unified -o my_config.toml

# Disable environment variable substitution
uv run python -m src.multi_config_generator *.log --no-env-vars

配置策略:

Windows目标(Win32/Win64/Win64x)使用MSBuild,它从.dproj文件读取所有编译器设置。只有最低限度 delphi_config.toml 需要Delphi安装路径。交叉编译目标(Linux64/Android/Android64)仍然需要完整的特定于平台的配置文件。

平台配置文件内容
Win32/Win64/Win64xdelphi_config.toml最小(仅 [delphi] 部分)
Linux 64delphi_config_linux64.toml完整(路径、标志、SDK)
安卓delphi_config_android.toml完整(路径、标志、NDK)
安卓64delphi_config_android64.toml完整(路径、标志、NDK)

配置搜索顺序:

  1. DELPHI_CONFIG 环境变量(显式覆盖)
  2. delphi_config_{platform}.toml (特定平台)
  3. delphi_config.toml (通用回退--仅限Windows目标)

或者使用Python API:

from src.config_generator import ConfigGenerator
from src.multi_config_generator import MultiConfigGenerator
from pathlib import Path

# Single build log
generator = ConfigGenerator()
result = generator.generate_from_build_log(
    build_log_path=Path("build.log"),
    output_path=Path("delphi_config.toml")
)

# Multiple build logs (recommended for multi-platform)
multi_gen = MultiConfigGenerator()
result = multi_gen.generate_from_build_logs(
    build_log_paths=["build_debug_win32.log", "build_release_win64.log", "build_debug_linux64.log"],
    output_path=Path("delphi_config.toml")
)
print(result.message)

3.配置克劳德代码

编辑 %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "delphi-build": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "C:\\path\\to\\delphi-build-mcp-server",
        "main.py"
      ],
      "env": {
        "DELPHI_CONFIG": "C:\\path\\to\\delphi-build-mcp-server\\delphi_config.toml"
      }
    }
  }
}

服务器选项

服务器支持两种传输模式:

标志默认值描述
--transportstdio运输类型: stdiostreamable-http
--host0.0.0.0绑定地址(仅限可流式传输的http)
--port8080监听端口(仅限可流式传输的http)

本地(stdio,默认):

uv run main.py

网络(流式HTTP):

uv run main.py --transport streamable-http
# Server listens on http://0.0.0.0:8080/mcp

在WSL Ubuntu中配置Claude代码

从WSL Ubuntu使用Delphi MCP服务器的两个选项:

选项1:通过WSL互操作进行stdio(最简单)

WSL可以直接执行Windows二进制文件。这通过Windows Python使用stdio传输——不需要HTTP服务器,也不需要手动启动。Claude Code自动管理服务器生命周期。

编辑 ~/.claude.json (或项目级别 .mcp.json)在WSL中:

{
  "mcpServers": {
    "delphi-build": {
      "command": "/mnt/c/Users//path/to/delphi-build-mcp-server/.venv/Scripts/python.exe",
      "args": [
        "/mnt/c/Users//path/to/delphi-build-mcp-server/main.py"
      ],
      "env": {
        "DELPHI_CONFIG": "C:\\Users\\\\path\\to\\delphi_config.toml"
      }
    }
  }
}
注:DELPHI_CONFIG 由于服务器作为Windows进程运行,因此路径必须使用Windows样式的路径。

选项2:流式HTTP(网络传输)

在Windows上将MCP服务器作为持久HTTP服务运行,并通过网络从WSL连接。

1.在Windows上启动MCP服务器:

cd C:\path\to\delphi-build-mcp-server
uv run main.py --transport streamable-http

要在登录时自动启动服务器,请放置 start_mcp_server.bat (包含在此存储库中)位于Windows启动文件夹中(Win+Rshell:startup).

2.从WSL查找您的Windows主机IP:

# Method 1: WSL gateway IP
cat /etc/resolv.conf | grep nameserver | awk '{print $2}'

# Method 2: Windows hostname
hostname -I  # run on Windows side

3.在WSL中配置Claude代码:

编辑 ~/.claude.json (或项目级别 .mcp.json):

{
  "mcpServers": {
    "delphi-build": {
      "url": "http://:8080/mcp"
    }
  }
}
注: 如果连接被拒绝,您可能需要通过Windows防火墙允许端口8080: ``powershell netsh advfirewall firewall add rule name="Delphi MCP Server" dir=in action=allow protocol=TCP localport=8080 ``

4.在克劳德代码中使用

Please compile my Delphi project at X:\MyProject\MyApp.dproj

工具

compile_delphi_project

编译一个Delphi项目并返回解析结果。

参数:

  • project_path (必需):.dpr或.dproj文件的路径
  • force_build_all:部队重建所有部队
  • override_config:覆盖构建配置(调试/发布)
  • override_platform:覆盖平台(Win32/Win64/Win64x/Linux64)
  • additional_search_paths:额外的搜索路径
  • additional_flags:其他编译器标志

退货:

  • success:编译是否成功
  • errors:编译错误列表(已筛选警告/提示)
  • compilation_time_seconds:所需时间
  • output_executable:编译EXE的路径
  • statistics:汇编统计

generate_config_from_build_log

生成 delphi_config.toml 从单个IDE构建日志中。

参数:

  • build_log_path (必需):生成日志文件的路径
  • output_config_path:输出文件路径(覆盖默认的特定于平台的命名)
  • use_platform_specific_name:根据检测到的平台生成特定于平台的文件名(例如,delphi_config_win64.toml)(默认值:true)
  • use_env_vars:将路径替换为${USERNAME}(默认值:true)

退货:

  • success:生成是否成功
  • config_file_path:生成配置的路径
  • statistics:找到并处理路径
  • detected_info:Delphi版本、平台、构建配置

generate_config_from_multiple_build_logs

从不同配置和平台的多个IDE构建日志中生成配置。默认情况下,创建单独的特定于平台的文件(例如,delphi_config \_win32.toml、delphi_config_win64.toml)。

参数:

  • build_log_paths (必需):IDE构建日志文件的路径数组(例如,Debug-Win32、Release-Win64、Debug-Linux64)
  • output_config_path:统一配置的输出文件路径(仅在generate_siseparate_files=false时使用)
  • generate_separate_files:生成单独的特定于平台的配置文件(默认值:true)。对于单个统一配置,设置为false。
  • output_dir:生成文件的输出目录(默认:当前目录)
  • use_env_vars:将路径替换为${USERNAME}(默认值:true)

退货:

  • success:生成是否成功
  • config_file_path:生成配置的路径
  • build_logs_processed:每个已处理日志的详细信息(路径、配置、平台、自动检测)
  • statistics:找到配置、找到平台、总库路径、生成的文件

extend_config_from_build_log

扩展现有 delphi_config.toml 使用新IDE构建日志中的设置。可用于添加对新平台(例如Win64x)或库的支持,而无需重新生成整个配置。

参数:

  • existing_config_path (必填):现有delphi_config.toml的路径
  • build_log_path (必需):IDE构建日志文件的路径
  • output_config_path:输出路径(默认:覆盖现有路径)
  • use_env_vars:将路径替换为${USERNAME}(默认值:true)

退货:

  • success:扩展是否成功
  • config_file_path:扩展配置的路径
  • paths_added:添加的新路径数
  • paths_skipped:跳过的重复项数
  • platforms_added:新平台列表(例如\[“Win64x”\])
  • settings_updated:每个部分更新的设置计数

文档

项目结构

delphi-build-mcp-server/
|-- main.py                       # MCP server entry point (stdio + streamable-http)
|-- src/
|   |-- models.py                 # Pydantic data models
|   |-- buildlog_parser.py        # Parse IDE build logs
|   |-- dproj_parser.py           # Parse .dproj files
|   |-- config.py                 # Load TOML configuration
|   |-- output_parser.py          # Parse dcc compiler output
|   |-- msbuild_output_parser.py  # Parse MSBuild output (extracts _PasCoreCompile)
|   |-- msbuild_compiler.py       # MSBuild compilation for Windows targets
|   |-- rsvars_parser.py          # Parse rsvars.bat for MSBuild environment
|   |-- config_generator.py       # Generate TOML configs (single log)
|   |-- multi_config_generator.py # Generate TOML configs (multi-log)
|   |-- config_extender.py        # Extend existing TOML configs
|   +-- compiler.py               # Direct dcc compilation for cross-compilation
|-- tests/                        # Unit tests
|-- start_mcp_server.bat          # Auto-start script for Windows (shell:startup)
|-- test_stdio_wsl.sh             # Test stdio transport from WSL
|-- test_http_transport.sh        # Test Streamable HTTP transport (bash)
|-- test_http_transport.bat       # Test Streamable HTTP transport (Windows)
|-- delphi_config.toml.template   # Configuration template
|-- pyproject.toml                # Python project config
|-- QUICKSTART.md                 # Quick start guide
+-- DOCUMENTATION.md              # Complete documentation

需求

  • Python 3.10+
  • 德尔菲11、12或13
  • MCP兼容客户端(Claude Code、Cline等)

运作原理

注: 服务器自动处理具有80多个库路径(命令行>8000个字符)的项目的响应文件,并解析英语和德语编译器输出。

1. AI Agent calls compile_delphi_project
   |
   v
2. Parse .dproj file to determine platform
   |
   v
3. Route based on platform:
   |
   +---> Windows (Win32/Win64/Win64x):
   |     - Load minimal config (delphi.root_path only)
   |     - Set up MSBuild environment from rsvars.bat
   |     - Execute msbuild.exe (IDE-identical output)
   |     - Parse _PasCoreCompile section for errors
   |
   +---> Cross-compilation (Linux64/Android/Android64):
         - Load full platform-specific config
         - Build dcc compiler command
         - Execute dcc32/dcc64/dcclinux64/dccaarm64
         - Parse compiler output for errors
   |
   v
4. Return structured result to AI

示例用法

编译项目

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"[OK] Compilation successful: {result.output_executable}")
else:
    print(f"[FAIL] Compilation failed with {len(result.errors)} errors:")
    for error in result.errors:
        print(f"  {error.file}({error.line},{error.column}): {error.message}")

从构建日志生成配置

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"[OK] {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']}")

从多个构建日志生成多平台配置

from src.multi_config_generator import MultiConfigGenerator
from pathlib import Path

generator = MultiConfigGenerator(use_env_vars=True)
result = generator.generate_from_build_logs(
    build_log_paths=[
        "build_debug_win32.log",
        "build_release_win32.log",
        "build_debug_linux64.log",
        "build_release_linux64.log"
    ],
    output_path=Path("delphi_config.toml")
)

print(f"[OK] {result.message}")
print(f"  Configs: {result.statistics['configs_found']}")
print(f"  Platforms: {result.statistics['platforms_found']}")
print(f"  Total paths: {result.statistics['total_library_paths']}")

使用新平台扩展现有配置

from src.config_extender import ConfigExtender
from pathlib import Path

# Extend existing config with Win64x platform support
extender = ConfigExtender(use_env_vars=True)
result = extender.extend_from_build_log(
    existing_config_path=Path("delphi_config.toml"),
    build_log_path=Path("build_win64x.log")
)

print(f"[OK] {result.message}")
print(f"  New platforms: {result.platforms_added}")
print(f"  Paths added: {result.paths_added}")
print(f"  Paths skipped (duplicates): {result.paths_skipped}")

或者通过CLI:

uv run python -m src.config_extender delphi_config.toml build_win64x.log
uv run python -m src.config_extender delphi_config.toml build_win64x.log -o extended_config.toml

故障排除

“找不到配置文件”

从构建日志生成它:

uv run python -m src.config_generator build.log

“未找到单位”

从包含所有依赖项的新IDE构建日志中重新生成配置。

“找不到编译器”

验证 delphi.root_pathdelphi_config.toml 指向您的Delphi安装。

发展

安装开发依赖项

uv pip install -e ".[dev]"

运行测试

uv run pytest

测试样本项目

包括两个示例项目进行测试:

# Test successful compilation
uv run python test_compile_samples.py
  • 样品/工作/加工.dproj -编译成功
  • 样品/破损/破碎.dproj -故意在测试错误解析时出错

代码格式化

uv run black src/
uv run ruff check src/

贡献

欢迎投稿!请参阅CONTRIBUTING.md了解指南。

许可证

MIT许可证-有关详细信息,请参阅许可证文件。

支持

  • 文档: 文件.md
  • 快速开始: QUICKSTART.md
  • 问题: https://github.com/basti-fantasti/delphi-build-mcp-server/issues

致谢

目录标签

目录标签

PythonClaude开发工具Delphi编译本地部署AI编程跨平台编译自动化构建IDE集成

支持客户端

ClaudeCline

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

4

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP