loading…
Search for a command to run...
loading…
Enables AI assistants to compile Delphi projects and single units directly through the Model Context Protocol. It features automatic compiler detection via the
Enables AI assistants to compile Delphi projects and single units directly through the Model Context Protocol. It features automatic compiler detection via the Windows registry and supports MSBuild with full build event integration.
一个为 AI 助手(如 Claude Desktop、CodeArts Agent 等)提供 Delphi 工程编译能力和知识库查询功能的 MCP Server。如果您觉得有用,请不要吝啬您的 Star! ⭐
Delphi MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,它允许 AI 助手直接编译 Delphi 项目并查询 Delphi 知识库。通过这个工具,您可以在与 AI 助手的对话中直接编译 Delphi 工程、查询 API 文档、搜索代码示例,无需手动切换到 IDE 或命令行。
主要优势:
| 工具名称 | 功能描述 | 主要参数 |
|---|---|---|
compile_project |
编译 Delphi 项目或检查 .pas 文件语法 | project_path, target_platform(win32/win64), build_configuration(Debug/Release), output_path, timeout, debug_info_enabled, get_args_only(可选) |
check_environment |
诊断编译环境、检测编译器、安装pasfmt | action(check/detect/install/format_install), search_path, install_dir, delphi_version |
install_package |
编译并安装 Delphi 组件包到 IDE | package_path, target_platform, build_configuration, timeout, install |
list_installed_packages |
列出已安装到 IDE 的 Delphi 组件包 | - |
get_coding_rules |
获取 Delphi 编码规范(命名/格式化/审核规则) | project_path(可选) |
| 工具名称 | 功能描述 | 主要参数 |
|---|---|---|
search_knowledge |
搜索代码/类/函数/文档,构建/查看知识库 | action(search/stats/build), query, kb_type(all/delphi/project/thirdparty/help), project_path, search_type, top_k, async_mode, force_rebuild |
| 工具名称 | 功能描述 | 主要参数 |
|---|---|---|
read_source_file |
读取指定文件内容或搜索类/函数位置 | file_path, search_type(path/class/function), type_name, function_name, search_in, start_line, max_lines |
| 工具名称 | 功能描述 | 主要参数 |
|---|---|---|
format_delphi |
格式化 Delphi 源码/代码,检查/设置 pasfmt | action(file/code/check/set_path/status), file_path, code, backup, in_place, path, check_rad, delphi_version |
| 工具名称 | 功能描述 | 主要参数 |
|---|---|---|
async_task |
管理后台任务(构建知识库等) | action(start/status/result/list/cancel), task_id, task_type, task_params, show_progress |
请按以下步骤安装 Delphi MCP Server:
[] 检查并安装 Git/Python 3.10-3.14/7-Zip (安装时优先使用国内镜像源加速下载)
[] 安装 https://github.com/chinawsb/delphi-complier-mcp-server.git
[] 安装完成后验证结果并帮我配置当前客户端
git clone https://github.com/chinawsb/delphi-complier-mcp-server.git
cd delphi-complier-mcp-server
python -m venv venv
Windows:
venv\Scripts\activate
Linux/macOS:
source venv/bin/activate
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
可选国内镜像源:
首次使用时,MCP Server 会自动从 Windows 注册表检测已安装的 Delphi 编译器,无需手动配置。
自动检测支持的 Delphi 版本:
如果需要手动配置或添加自定义编译器,可以直接编辑 config/compilers.json 文件,或使用 check_environment 工具的 detect action 重新检测。
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"
}
}
}
}
Windows: C:\Users\<用户名>\.trae-cn\mcp_config.json
{
"mcpServers": {
"delphi-compiler": {
"command": "F:\\ProPlus\\DelphiPlus\\Experts\\DelphiMCPServer\\delphi-complier-mcp-server\\venv\\Scripts\\python.exe",
"args": [
"F:\\ProPlus\\DelphiPlus\\Experts\\DelphiMCPServer\\delphi-complier-mcp-server\\src\\server.py"
],
"env": {
"PYTHONUNBUFFERED": "1",
"PYTHONIOENCODING": "utf-8",
"PYTHONUTF8": "1"
}
}
}
}
注意: 请将路径修改为您的实际安装路径。
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 工程或检查 .pas 文件语法 | project_path, get_args_only(可选) |
check_environment |
诊断编译环境问题 | action(check/detect/install/format_install) |
| 工具名称 | 功能描述 | 必需参数 |
|---|---|---|
search_knowledge |
搜索代码/类/函数/文档,构建/查看知识库 | action(search/stats/build), query |
| 工具名称 | 功能描述 | 必需参数 |
|---|---|---|
read_source_file |
读取指定文件或搜索类/函数位置 | file_path, search_type(path/class/function) |
| 工具名称 | 功能描述 | 必需参数 |
|---|---|---|
format_delphi |
格式化源码/代码,检查/设置 pasfmt | action(file/code/check/set_path/status) |
| 工具名称 | 功能描述 | 必需参数 |
|---|---|---|
async_task |
管理后台任务 | action(start/status/result/list/cancel) |
| 工具名称 | 功能描述 | 必需参数 |
|---|---|---|
get_coding_rules |
获取 Delphi 编码规范 | project_path(可选) |
| 知识库类型 | 位置 | 说明 |
|---|---|---|
| Delphi 源码知识库 | data/delphi-knowledge-base/ |
Delphi 官方源码,全局共享 |
| 帮助文档知识库 | data/help-knowledge-base/ |
Delphi CHM 帮助文档,全局共享 |
| 项目知识库 | <项目目录>/.delphi-kb/ |
项目特定,包含三方库和项目源码 |
| 知识库 | 文档数 | 类数量 | 函数数量 |
|---|---|---|---|
| Delphi 源码 | 3,081 | 17,731 | 168,925 |
| 帮助文档 | 160,174 | - | - |
解决方案:
config/compilers.json 文件中的编译器路径是否正确check_environment 工具 action=detect 重新检测编译器解决方案:
pip install -r requirements.txtpip show mcp解决方案:
build_knowledge_base 工具MIT License
Copyright (c) 2026 吉林省左右软件开发有限公司 Copyright (c) 2026 Equilibrium Software Development Co., Ltd, Jilin
详见 LICENSE 文件。
check_environment: detect action 参数传递错误;补充 install/format_install action 实现search_knowledge: 搜索结果文件路径显示 N/A(键名错误);search_type 过滤未生效config.set_config_manager 导致 search_compilers 报配置管理器未初始化get_coding_rules 工具,通过 MCP tool 接口暴露编码规范delphi://coding-rules),AI Agent 可通过 resources 协议读取编码规则新增安装脚本 install.ps1
完善 AI Agent 检测逻辑
新增组件包安装工具
install_package: 编译并安装 .dproj/.dpk/.groupproj 组件包到 IDElist_installed_packages: 列出已安装到 IDE 的组件包优化编码规范(见上文)
修复编译参数问题
$(BDSLIB) 宏展开路径错误(原路径 lib\$(Platform) 导致双重展开)BDSCOMMONDIR 环境变量分割逻辑错误asyncio.create_subprocess_exec 自动处理空格路径)-NS 参数解决 SysUtils 等单元解析问题修复项目依赖分析
统一工具返回类型
compile_project 返回 CallToolResultcompile_file 返回 CallToolResultget_compiler_args 返回 CallToolResult工具整合
search_knowledgebuild_knowledgeget_knowledge_stats所有 pytest 测试通过 (15/15)
新增路径宏展开工具
src/utils/delphi_env.py 工具模块$(BDS), $(BDSCatalogRepository), $(BDSUSERDIR) 等路径宏展开get_catalog_repository_paths() 函数获取 GetIt 组件源码路径resolve_delphi_search_paths() 函数整合所有搜索路径优化第三方库路径处理
重建知识库
修复工具返回类型问题
search_compilers 返回类型为 CallToolResultget_compiler_args 返回类型为 CallToolResultget_coding_rules 返回类型为 CallToolResultcheck_pasfmt_installation 返回类型为 CallToolResultformat_code 返回类型为 CallToolResult修复搜索结果显示问题
knowledge_base.py 中 [:3] 限制为使用 top_k 参数修复项目依赖分析
analyze_project_dependencies 除零错误(当项目单元数为0时)修复知识库自动加载
read_source_file 知识库未自动加载问题所有 pytest 测试通过 (11/11)
format_delphi_file 工具,格式化 Delphi 源代码文件format_delphi_code 工具,格式化 Delphi 代码字符串install_pasfmt 工具,下载并安装 pasfmt CLI 或 IDE 插件check_pasfmt_installation 工具,检查 pasfmt 安装状态set_pasfmt_path 工具,设置 pasfmt 可执行文件路径build_help_kb_index 工具,构建帮助文档向量索引search_help 支持语义搜索类、函数和文档analyze_project_dependencies 工具,分析项目单元依赖关系resolve_smart_library_paths 工具,智能解析项目需要的第三方库路径compile_project 支持智能库路径解析,自动分析项目依赖并选择需要的库路径read_source_file 工具,先在知识库中定位文件,再从磁盘读取源码内容search_and_read_file 工具,搜索类型(类/record/interface)或函数并自动读取所在文件内容search_by_filename 工具,支持按文件名通配符搜索type_kind 字段,显示类型种类(class/record/interface/enum)get_thirdparty_paths 工具,获取第三方库路径列表search_thirdparty_class 工具,在第三方库中搜索类search_thirdparty_function 工具,在第三方库中搜索函数semantic_search_thirdparty 工具,在第三方库中进行语义搜索get_thirdparty_kb_stats 工具,获取第三方库知识库统计信息get_task_status 工具,查询后台任务状态list_tasks 工具,列出所有后台任务get_coding_rules 工具,用于获取 Delphi 源码编码规则欢迎提交 Issue 和 Pull Request!
如有问题或建议,请提交 Issue。
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"delphi-compiler-mcp-server": {
"command": "npx",
"args": []
}
}
}