这是一个基于模型上下文协议(MCP)的服务器,提供了35个全面工具,这些工具被组织成5个主要类别,用于处理EnergyPlus建筑能源模拟模型。该服务器使AI助手和其他MCP客户端能够通过标准化接口加载、验证、修改和分析EnergyPlus IDF(输入数据文件)模型。
版本: 0.1.0
EnergyPlus兼容性: 25.1.0
Python: 3.10+
这个仓库包含了一个专门为EnergyPlus建筑能源模拟工作流程设计的MCP服务器。EnergyPlus是一个强大的建筑能源模拟引擎,而这个MCP服务器使其可以被AI助手和自动化工具访问。
关键特性:
EnergyPlus MCP服务器遵循分层架构,明确区分关注点:
这种架构使得与AI助手、IDE和其他MCP客户端的可扩展集成成为可能,同时保持了强大的错误处理和企业级日志记录能力。
EnergyPlus MCP服务器提供了35个全面工具,这些工具被组织成5个主要类别,如架构图所示:
copy_file - 智能文件复制,具有路径解析和模糊匹配功能load_idf_model - 加载并验证EnergyPlus IDF文件,带有详细的错误报告list_available_files - 浏览示例文件、示例文件和天气数据get_model_summary - 提取基本模型信息(建筑物、站点、模拟控制、版本)validate_idf - 全面的模型验证,带有警告和错误check_simulation_settings - 查看当前模拟控制和运行周期设置modify_simulation_control - 修改模拟控制参数(运行周期、尺寸等)modify_run_period - 调整模拟时间段和日期get_server_configuration - 获取详细的服务器配置和版本信息list_zones - 列出所有热区及其详细属性get_surfaces - 获取全面的建筑表面信息和几何形状get_materials - 提取材料和构造定义inspect_schedules - 深入分析所有时间表对象,并支持值提取inspect_people - 对People对象进行详细分析,包括占用计算和热舒适设置inspect_lights - 对Lights对象进行全面分析,包括功率计算和热量分数inspect_electric_equipment - 对ElectricEquipment对象进行全面分析,包括功率计算和热量分数get_output_variables - 获取已配置的变量或发现所有可用的输出变量get_output_meters - 获取已配置的计量器或发现所有可用的能量计量器modify_people - 使用灵活的目标修改People对象(全部、按区域或按名称)modify_lights - 支持不同计算方法的Lights对象修改modify_electric_equipment - 支持不同计算方法的ElectricEquipment对象修改change_infiltration_by_mult - 通过乘数因子修改渗透率add_window_film_outside - 向外部玻璃添加窗户膜,具有自定义属性add_coating_outside - 应用外部表面涂层(墙壁/屋顶),具有热性能add_output_variables - 添加输出变量,具有智能验证和格式化add_output_meters - 添加输出计量器,具有灵活的指定格式run_energyplus_simulation - 使用天气文件执行完整的EnergyPlus模拟create_interactive_plot - 从模拟结果生成交互式HTML图表discover_hvac_loops - 发现模型中的所有暖通空调循环(植物、冷凝器、空气)get_loop_topology - 获取特定暖通空调循环的详细拓扑结构,包括组件和连接visualize_loop_diagram - 生成暖通空调系统拓扑和流路径的视觉图get_server_status - 检查服务器健康状况、性能和系统信息get_server_logs - 获取最近的服务器日志条目以供调试get_error_logs - 获取最近的错误日志条目以供故障排除clear_logs - 清除/轮换当前日志文件,自动备份sample_files/: 示例EnergyPlus IDF文件和天气数据
1ZoneUncontrolled.idf: 简单的单区模型1ZoneEvapCooler.idf: 单区带蒸发冷却5ZoneAirCooled.idf: 多区空气冷却模型USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw: 旧金山的天气文件energyplus_mcp_server/: 服务器实现
server.py: 包含所有可用工具的FastMCP服务器energyplus_tools.py: EnergyPlus文件操作实用程序config.py: 配置管理
utils/: 高级实用模块
schedules.py: 综合的时间表解析、分析和修改实用程序diagrams.py: 暖通空调图生成和可视化工具pyproject.toml: 项目元数据和依赖项
outputs/: 模拟输出和修改文件的目录
最简单的方法是使用VS Code开发容器,它提供了一个完全配置好的环境,其中预装了EnergyPlus。
前提条件:
步骤:
克隆仓库:
git clone https://github.com/tsbyq/EnergyPlus_MCP.git
cd EnergyPlus_MCP
在VS Code中打开:
code .
当提示时,点击“在容器中重新打开”或:
Ctrl+Shift+P容器会自动:
uv设置Python依赖项uv sync --extra dev以安装所有依赖项开发容器中包含的内容:
uv包管理器的Python 3.11+开发容器设置定义在.devcontainer/文件夹中:
Dockerfile: 包含EnergyPlus和Python设置的容器镜像devcontainer.json: VS Code配置、扩展和端口转发如果你更喜欢直接使用Docker而不使用VS Code:
前提条件:
步骤:
克隆仓库:
git clone https://github.com/tsbyq/EnergyPlus_MCP.git
cd EnergyPlus_MCP
构建开发容器:
docker build -t energyplus-mcp-dev -f .devcontainer/Dockerfile .
运行容器并挂载卷:
docker run -it --rm -v "%cd%":/workspace -w /workspace/energyplus-mcp-server energyplus-mcp-dev bash
在容器内安装依赖项:
uv sync --extra dev
对于不使用容器的本地开发(需要手动安装EnergyPlus):
前提条件:
步骤:
克隆并导航到服务器目录:
git clone https://github.com/tsbyq/EnergyPlus_MCP.git
cd EnergyPlus_MCP\energyplus-mcp-server
安装依赖项:
uv sync --extra dev
在你的环境中或配置文件中配置EnergyPlus路径(服务器将在标准安装位置查找EnergyPlus)。
根据需求,EnergyPlus MCP服务器可以有多种使用方式:
主要用途是将服务器连接到兼容MCP的AI助手(如Claude Desktop、VS Code Copilot或其他MCP客户端)。
启动服务器:
cd energyplus-mcp-server
uv run python -m energyplus_mcp_server.server
服务器将以STDIO模式启动,并可以连接到MCP客户端。
示例MCP客户端配置(针对Claude Desktop):
{
"mcpServers": {
"energyplus": {
"command": "uv",
"args": ["run", "python", "-m", "energyplus_mcp_server.server"],
"cwd": "/path/to/energyplus-mcp-server"
}
}
}
使用MCP Inspector(如果可用):
uv run mcp-inspector energyplus_mcp_server.server
这将打开一个Web界面,用于交互式测试MCP工具。
直接使用Python:
# 在Python环境或Jupyter笔记本中
from energyplus_mcp_server.energyplus_tools import EnergyPlusManager
ep_manager = EnergyPlusManager()
# 加载示例模型
result = ep_manager.load_idf("1ZoneUncontrolled.idf")
print(result)
# 获取模型摘要
summary = ep_manager.get_model_basics("1ZoneUncontrolled.idf")
print(summary)
加载并验证IDF文件:
{
"tool": "load_idf_model",
"arguments": {
"idf_path": "sample_files/1ZoneUncontrolled.idf"
}
}
修改模拟设置:
{
"tool": "modify_simulation_control",
"arguments": {
"idf_path": "sample_files/1ZoneUncontrolled.idf",
"field_updates": {
"Run_Simulation_for_Weather_File_Run_Periods": "Yes",
"Do_Zone_Sizing_Calculation": "Yes"
},
"output_path": "outputs/modified_model.idf"
}
}
列出模型中的区域:
{
"tool": "list_zones",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf"
}
}
检查模型中的时间表:
{
"tool": "inspect_schedules",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf",
"include_values": true
}
}
修改渗透率:
{
"tool": "change_infiltration_by_mult",
"arguments": {
"idf_path": "sample_files/1ZoneUncontrolled.idf",
"mult": 0.5,
"output_path": "outputs/reduced_infiltration.idf"
}
}
向外部表面添加窗户膜:
{
"tool": "add_window_film_outside",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf",
"u_value": 3.5,
"shgc": 0.35,
"visible_transmittance": 0.60,
"output_path": "outputs/with_window_film.idf"
}
}
向外部表面添加涂层:
{
"tool": "add_coating_outside",
"arguments": {
"idf_path": "sample_files/1ZoneUncontrolled.idf",
"location": "Wall",
"solar_abs": 0.3,
"thermal_abs": 0.8,
"output_path": "outputs/with_coating.idf"
}
}
获取可用的示例文件:
{
"tool": "list_sample_files",
"arguments": {}
}
获取已配置的输出变量:
{
"tool": "get_output_variables",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf"
}
}
发现所有可用的输出变量:
{
"tool": "get_output_variables",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf",
"discover_available": true,
"run_days": 1
}
}
获取已配置的输出计量器:
{
"tool": "get_output_meters",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf"
}
}
发现所有可用的输出计量器:
{
"tool": "get_output_meters",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf",
"discover_available": true,
"run_days": 1
}
}
发现暖通空调循环:
{
"tool": "discover_hvac_loops",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf"
}
}
可视化暖通空调循环图:
{
"tool": "visualize_loop_diagram",
"arguments": {
"idf_path": "sample_files/5ZoneAirCooled.idf",
"loop_name": "Hot Water Loop",
"output_path": "outputs/hvac_diagram.png",
"format": "png"
}
}
运行EnergyPlus模拟:
{
"tool": "run_energyplus_simulation",
"arguments": {
"idf_path": "sample_files/1ZoneUncontrolled.idf",
"weather_file": "sample_files/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw",
"annual": true,
"readvars": true
}
}
从模拟结果生成交互式图表:
{
"tool": "create_interactive_plot",
"arguments": {
"output_directory": "outputs/1ZoneUncontrolled",
"file_type": "auto",
"custom_title": "区域温度分析"
}
}
获取服务器日志以供调试:
{
"tool": "get_server_logs",
"arguments": {
"lines": 100
}
}
服务器提供了高级的暖通空调系统分析能力,包括拓扑检测和可视化图生成:
暖通空调分析功能: