mcpField
P
PyPSA MCP: Energy Modeling for LLMs

PyPSA MCP: Energy Modeling for LLMs

本地服务
github.com/cdgaete科研与教育7432 周前更新

关于 PyPSA MCP: Energy Modeling for LLMs

PyPSA MCP 是连接 LLM 与 PyPSA 的 MCP 服务,面向能源系统建模与分析。它支持通过自然语言构建网络、运行潮流计算和优化,并分析结果。

主要功能

  1. 01创建和管理能源模型
  2. 02添加并配置网络组件
  3. 03设置仿真时间序列
  4. 04运行潮流计算与优化
  5. 05提取并导出分析结果

适用场景

  1. 01用自然语言构建电力系统模型
  2. 02设置负荷和发电时间序列
  3. 03验证网络潮流并优化调度

MCP 相关

该 MCP 服务向客户端提供模型管理、组件创建、仿真、优化和结果分析工具,使 LLM 能够与 PyPSA 交互。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

PyPSA MCP

PyPSA MCP 是一个 Model Context Protocol (MCP) 服务,用于使用 PyPSA(Python for Power System Analysis)创建、分析和优化能源系统模型。

一个 Model Context Protocol (MCP) 服务,使 Claude 等大模型能够通过自然语言与 PyPSA 交互,进行能源模型的创建和分析。

演示示例

以下是一个演示视频,展示如何将 PyPSA MCP 与 Claude 配合使用。视频演示了创建简单的两母线模型、运行潮流计算以及执行优化。

https://github.com/user-attachments/assets/5633a431-7c3b-4a2f-9a9e-395dcbbb2e29

演示提示词

你可以使用以下提示词与 Claude 复现视频中展示的示例:

I'd like to build an energy system model and perform optimization using PyPSA. Please help me with these steps: 
1. Create a simple two-bus model with: 
   1. Two buses at (0,0) and (100,0) with 220 kV nominal voltage 
   2. A generator at bus1 with 100 MW capacity and 50 €/MWh cost 
   3. A load at bus2 with 80 MW demand
   4. 24 hourly snapshots for January 1, 2025
2. Run a power flow calculation to verify the model 
3. Perform optimization with the highs solver using the kirchhoff formulation 
4. Discuss the results

概述

PyPSA MCP 在大模型与 PyPSA 之间架起桥梁,让你可以:

  1. 通过自然语言创建和管理能源系统模型
  2. 添加母线、发电机和输电线路等网络组件
  3. 为仿真设置时间序列数据
  4. 运行潮流和优化计算
  5. 分析结果

功能

  • 模型管理

    • 创建新的 PyPSA 能源模型
    • 列出并选择可用模型
    • 导出详细的模型摘要
    • 在不再需要时删除模型
  • 组件创建

    • 添加母线、发电机、负荷和其他网络组件
    • 通过自然语言配置组件参数
    • 修改现有组件
    • 将组件组织为有意义的组
  • 数据与仿真

    • 为仿真时段设置时间快照
    • 为负荷和发电机添加时间序列数据
    • 运行潮流计算
    • 使用各种求解器和公式进行优化
  • 结果分析

    • 从仿真结果中提取关键指标
    • 生成模型性能摘要
    • 导出数据以供进一步分析

安装

前置条件
  • Python 3.10 或更高版本
  • uv(推荐,便于依赖管理)
主要安装方式(PyPI)
# Install from PyPI
pip install pypsamcp

# Or using uv (recommended)
uv pip install pypsamcp
运行 PyPSA MCP
# Run using the installed package
pypsamcp
在 Claude Desktop 中配置
  1. 找到 Claude Desktop 的配置文件(通常位于 ~/.config/Claude/config.json)

  2. 将 PyPSA MCP 添加到 mcpServers 部分:

    "mcpServers": {
      "PyPSA MCP":{
        "command": "uv",  # Sometimes /path/to/local/uv (remove this comment)
        "args": [
          "run",
          "--with",
          "pypsamcp",
          "pypsamcp"
        ]
      }
    }
    
  3. 保存配置文件并重启 Claude Desktop

开发安装(从 GitHub)

适用于贡献者或希望修改代码的用户:

# Clone the repository
git clone https://github.com/cdgaete/pypsa-mcp.git
cd pypsa-mcp

# Install development dependencies with uv
uv pip install -e ".[dev]"
以开发模式运行
# Run the server directly
python -m pypsamcp.server

可用工具

该服务提供以下 MCP 工具:

模型管理
create_energy_model(
    id: str,
    name: str = None,
    description: str = None
)
list_models()
delete_model(
    id: str
)
export_model_summary(
    id: str,
    include_components: bool = True,
    include_parameters: bool = True
)
组件创建
add_bus(
    model_id: str,
    name: str,
    v_nom: float,
    x: float = 0.0,
    y: float = 0.0,
    carrier: str = "AC"
)
add_generator(
    model_id: str,
    name: str,
    bus: str,
    p_nom: float,
    marginal_cost: float = 0.0,
    carrier: str = "generator"
)
add_load(
    model_id: str,
    name: str,
    bus: str,
    p_set: float
)
add_line(
    model_id: str,
    name: str,
    bus0: str,
    bus1: str,
    x: float,
    r: float = 0.0,
    g: float = 0.0,
    b: float = 0.0,
    s_nom: float = 0.0
)
add_storage(
    model_id: str,
    name: str,
    bus: str,
    p_nom: float,
    max_hours: float,
    efficiency_store: float = 1.0,
    efficiency_dispatch: float = 1.0,
    standing_loss: float = 0.0
)
数据与仿真
set_snapshots(
    model_id: str,
    start_time: str,
    end_time: str,
    freq: str = "H"
)
run_powerflow(
    model_id: str,
    snapshot: str = None
)
run_optimization(
    model_id: str,
    solver_name: str = "glpk",
    formulation: str = "kirchhoff"
)

示例提示词

以下是一些将 PyPSA MCP 与 Claude 配合使用的示例:

Create a new energy system model with three buses, two generators, and a load.
Add a wind generator with 100 MW capacity to bus "bus1" with a marginal cost of 10.
Run a power flow calculation on the current model and show me the results.
Optimize the model using the GLPK solver and summarize the key findings.

许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

致谢

  • 基于 PyPSA 构建,用于电力系统建模
  • 使用 FastMCP 实现 Model Context Protocol
  • 灵感来源于通过自然语言接口让能源系统建模更易用的需求

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。