Delphi Compiler MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/chinawsb/delphi-complier-mcp-server.git
cd delphi-complier-mcp-server
python -m venv venv
pip install -r requirements.txt
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add delphi-compiler -- python "<FULL_PATH_TO_DELPHI_COMPLIER_MCP_SERVER>/dist/index.js"

Replace <FULL_PATH_TO_DELPHI_COMPLIER_MCP_SERVER>/dist/index.js with the actual folder you prepared in step 1.

README.md

Compile Delphi projects and query Delphi knowledge bases via MCP

Delphi MCP Server

一个为 AI 助手(如 Claude Desktop、CodeArts Agent 等)提供 Delphi 工程编译能力和知识库查询功能的 MCP Server。如果您觉得有用,请不要吝啬您的 Star! ⭐

项目简介

Delphi MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,它允许 AI 助手直接编译 Delphi 项目并查询 Delphi 知识库。通过这个工具,您可以在与 AI 助手的对话中直接编译 Delphi 工程、查询 API 文档、搜索代码示例,无需手动切换到 IDE 或命令行。

主要优势:

  • 无缝集成到 AI 助手工作流中
  • 自动检测和配置 Delphi 编译器
  • 内置 Delphi 源码知识库,支持语义搜索
  • 项目级知识库,自动追踪三方库和项目源码
  • 帮助文档知识库,快速查询 API 文档
  • 支持所有主流 AI 助手平台
  • 完整的编译事件支持
  • 详细的错误诊断和日志

功能特性

编译功能

  • 工程整体编译: 支持编译完整的 Delphi 工程(.dproj/.dpr),生成可执行文件或动态链接库
  • MSBuild 编译: 优先使用 MSBuild 编译,自动处理依赖关系和编译事件
  • 单文件编译: 支持编译单个 Delphi 单元文件(.pas),进行语法检查
  • 自动检测编译器: 自动从注册表检测已安装的 Delphi 编译器,无需手动配置
  • 编译事件支持: 支持 PreBuildEvent、PostBuildEvent、PreLinkEvent,包含完整的参数替换
  • 命令行参数生成: 支持生成 Delphi 编译器命令行参数,便于调试和预览
  • 编译器配置管理: 支持配置和管理多个 Delphi 编译器版本
  • 环境检查: 提供编译器环境状态检查功能
  • 丰富的编译选项: 支持条件编译符号、搜索路径、优化选项、调试信息、警告控制等

知识库功能

  • Delphi 源码知识库: 内置 Delphi 官方源码知识库,支持类、函数搜索和语义搜索
  • 项目知识库: 为每个项目构建独立知识库,自动追踪三方库和项目源码
  • 三方库知识库: 从 .dproj 文件自动提取三方库路径并构建知识库
  • 增量更新: 自动检测源码变动,增量更新项目知识库
  • 帮助文档知识库: 从 Delphi CHM 帮助文件提取内容,支持 API 文档查询

编码规范功能

  • 编码规则查询: 获取 Delphi 源码编码规则,供 AI 助手用于代码审核和生成
  • 默认规则支持: 内置默认编码规则文件,包含命名规则、格式化规则、修改规则和审核规则
  • 自定义规则支持: 支持项目级别的自定义编码规则,优先于默认规则
  • 规则优先级: 项目自定义规则 > 默认规则

系统要求

  • Python 3.10-3.14
  • Delphi 编译器(dcc32.exe 或 dcc64.exe)
  • Windows 操作系统
  • Git
  • 7-Zip (用于解压 CHM 帮助文件,可选)

安装

AI 助手自动安装提示词

请按以下步骤安装 Delphi MCP Server:

[] 检查并安装 Git/Python 3.10-3.14/7-Zip (安装时优先使用国内镜像源加速下载) [] 安装 https://github.com/chinawsb/delphi-complier-mcp-server.git [] 安装完成后验证结果并帮我配置当前客户端

手动安装步骤

1. 克隆或下载项目
git clone https://github.com/chinawsb/delphi-complier-mcp-server.git
cd delphi-complier-mcp-server
2. 创建虚拟环境
python -m venv venv
3. 激活虚拟环境

Windows:

venv\Scripts\activate

Linux/macOS:

source venv/bin/activate
4. 安装依赖 (使用国内镜像源加速)
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

可选国内镜像源:

配置 AI 助手

自动检测 Delphi 编译器

首次使用时,MCP Server 会自动从 Windows 注册表检测已安装的 Delphi 编译器,无需手动配置。

自动检测支持的 Delphi 版本:

  • Delphi 13 Florence (37.0)
  • Delphi 12 Athens (23.0)
  • Delphi 11 Alexandria (22.0)
  • Delphi 10.4 Sydney (21.0)
  • Delphi 10.3 Rio (20.0)
  • Delphi 10.2 Tokyo (19.0)
  • Delphi 10.1 Berlin (18.0)
  • Delphi 10 Seattle (17.0)
  • Delphi XE8 (16.0)
  • Delphi XE7 (15.0)
  • Delphi XE6 (14.0)
  • Delphi XE5 (12.0)
  • Delphi XE4 (11.0)
  • Delphi XE3 (10.0)
  • Delphi XE2 (9.0)
  • Delphi XE (8.0)
  • Delphi 2010 (7.0)
  • Delphi 2009 (6.0)
  • Delphi 2007 (5.0)
  • Delphi 2006 (4.0)
  • Delphi 2005 (3.0)

手动配置编译器 (可选)

如果需要手动配置或添加自定义编译器,可以通过 MCP 工具 set_compiler_config 进行配置,或直接编辑 config/compilers.json 文件。

配置 Claude Desktop

Claude Desktop

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "delphi-compiler": {
      "command": "python",
      "args": ["C:\\path\\to\\delphi_mcp_server\\src\\server.py"],
      "env": {
        "PYTHONUNBUFFERED": "1",
        "PYTHONIOENCODING": "utf-8",
        "PYTHONUTF8": "1"
      }
    }
  }
}

配置 CodeArts Agent

Windows: ~/.codeartsdoer/mcp/mcp_settings.json

{
  "mcpServers": {
    "delphi-compiler": {
      "command": "python",
      "args": ["src\\server.py"],
      "cwd": "C:\\path\\to\\delphi_mcp_server",
      "env": {
        "PYTHONUNBUFFERED": "1",
        "PYTHONIOENCODING": "utf-8",
        "PYTHONUTF8": "1"
      }
    }
  }
}

使用方法

编译工具

工具名称 功能描述
compile_project 编译 Delphi 工程
compile_file 编译单个 Delphi 单元文件(仅语法检查)
get_compiler_args 获取编译器命令行参数(不执行编译)
set_compiler_config 配置 Delphi 编译器
check_environment 检查编译器环境状态

知识库工具

工具名称 功能描述
build_knowledge_base 构建 Delphi 源码知识库
search_class 搜索 Delphi 类定义
search_function 搜索 Delphi 函数/过程定义
semantic_search 语义搜索 Delphi 代码
get_knowledge_base_stats 获取知识库统计信息
list_delphi_versions 列出已安装的 Delphi 版本

项目知识库工具

工具名称 功能描述
init_project_knowledge_base 初始化项目知识库
search_project_class 在项目中搜索类定义
search_project_function 在项目中搜索函数定义
semantic_search_project 在项目中进行语义搜索
get_project_kb_stats 获取项目知识库统计信息
get_thirdparty_paths 获取项目的三方库路径

帮助文档工具

工具名称 功能描述
build_help_knowledge_base 构建 Delphi 帮助文档知识库
search_help 搜索 Delphi 帮助文档
`get_help_kb_s

Tools (19)

compile_projectCompile a complete Delphi project (.dproj/.dpr)
compile_fileCompile a single Delphi unit file for syntax checking
get_compiler_argsGenerate and preview Delphi compiler command line arguments
set_compiler_configConfigure Delphi compiler settings
check_environmentCheck the status of the compiler environment
build_knowledge_baseBuild the Delphi source code knowledge base
search_classSearch for Delphi class definitions
search_functionSearch for Delphi function or procedure definitions
semantic_searchPerform semantic search on Delphi code
get_knowledge_base_statsRetrieve statistics for the knowledge base
list_delphi_versionsList all detected installed Delphi versions
init_project_knowledge_baseInitialize a knowledge base for a specific project
search_project_classSearch for class definitions within a specific project
search_project_functionSearch for function definitions within a specific project
semantic_search_projectPerform semantic search within a specific project
get_project_kb_statsGet statistics for a project-specific knowledge base
get_thirdparty_pathsRetrieve third-party library paths for a project
build_help_knowledge_baseBuild the Delphi help documentation knowledge base
search_helpSearch through Delphi help documentation

Environment Variables

PYTHONUNBUFFEREDEnsures Python output is sent directly to the terminal
PYTHONIOENCODINGSets the encoding for standard I/O
PYTHONUTF8Enables UTF-8 mode for Python

Configuration

claude_desktop_config.json
{"mcpServers": {"delphi-compiler": {"command": "python", "args": ["C:\\path\\to\\delphi_mcp_server\\src\\server.py"], "env": {"PYTHONUNBUFFERED": "1", "PYTHONIOENCODING": "utf-8", "PYTHONUTF8": "1"}}}}

Try it

Compile the current Delphi project and report any build errors.
Search the Delphi knowledge base for the definition of TObject.
Check if my Delphi compiler environment is correctly configured.
Find the definition of the 'CalculateTotal' function in my current project.
Search the Delphi help documentation for information on TStringList.

Frequently Asked Questions

What are the key features of Delphi Compiler MCP Server?

Automatic detection of installed Delphi compilers via Windows registry. Support for MSBuild and full build event integration. Built-in semantic search for Delphi source code and API documentation. Project-level knowledge base tracking for third-party libraries. Syntax checking for individual .pas files.

What can I use Delphi Compiler MCP Server for?

Automating the build process for Delphi projects directly from an AI chat interface. Quickly looking up Delphi API documentation without leaving the IDE or chat. Performing semantic code searches across large Delphi codebases. Validating Delphi code syntax during development sessions.

How do I install Delphi Compiler MCP Server?

Install Delphi Compiler MCP Server by running: git clone https://github.com/chinawsb/delphi-complier-mcp-server.git && cd delphi-complier-mcp-server && python -m venv venv && pip install -r requirements.txt

What MCP clients work with Delphi Compiler MCP Server?

Delphi Compiler MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Delphi Compiler MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare