Cover image
Try Now
2025-04-14

PYPSA MCP:LLMS的PYPSA能量建模

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

PyPSA MCP

PyPSA MCP is a Model Context Protocol (MCP) server for creating, analyzing, and optimizing energy system models using PyPSA (Python for Power System Analysis).

A Model Context Protocol (MCP) server that enables Large Language Models (LLMs) like Claude to interact with PyPSA for energy model creation and analysis via natural language.

Demo Example

Below is a demo video showing how to use PyPSA MCP with Claude. The video demonstrates creating a simple two-bus model, running power flow calculations, and performing optimization.

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

Demo Prompt

You can try this exact prompt with Claude to reproduce the example shown in the video:

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

Overview

PyPSA MCP provides a bridge between Large Language Models and PyPSA, allowing you to:

  1. Create and manage energy system models through natural language
  2. Add network components like buses, generators, and transmission lines
  3. Set up time series data for simulation
  4. Run power flow and optimization calculations
  5. Analyze results

Features

  • Model Management

    • Create new PyPSA energy models
    • List and select from available models
    • Export detailed model summaries
    • Delete models when no longer needed
  • Component Creation

    • Add buses, generators, loads, and other network components
    • Configure component parameters through natural language
    • Modify existing components
    • Organize components into meaningful groups
  • Data and Simulation

    • Set time snapshots for simulation periods
    • Add time series data for loads and generators
    • Run power flow calculations
    • Perform optimization with various solvers and formulations
  • Results Analysis

    • Extract key metrics from simulation results
    • Generate summaries of model performance
    • Export data for further analysis

Installation

Prerequisites

  • Python 3.10 or higher
  • uv (recommended for easy dependency management)

Main Installation (PyPI)

# Install from PyPI
pip install pypsamcp

# Or using uv (recommended)
uv pip install pypsamcp

Running PyPSA MCP

# Run using the installed package
pypsamcp

Configuring in Claude Desktop

  1. Locate Claude Desktop's configuration file (typically in ~/.config/Claude/config.json)

  2. Add PyPSA MCP to the mcpServers section:

    "mcpServers": {
      "PyPSA MCP":{
        "command": "uv",  # Sometimes /path/to/local/uv (remove this comment)
        "args": [
          "run",
          "--with",
          "pypsamcp",
          "pypsamcp"
        ]
      }
    }
    
  3. Save the configuration file and restart Claude Desktop

Development Installation (from GitHub)

For contributors or users who want to modify the code:

# 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]"

Running in Development Mode

# Run the server directly
python -m pypsamcp.server

Available Tools

The server provides the following MCP tools:

Model Management

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
)

Component Creation

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
)

Data and Simulation

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"
)

Example Prompts

Here are some examples of how to use PyPSA MCP with 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built on PyPSA for power system modeling
  • Uses FastMCP for the Model Context Protocol implementation
  • Inspired by the need to make energy system modeling more accessible through natural language interfaces

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • Byaidu
  • PDF科学纸翻译带有保留格式的pdf -基于ai完整保留排版的pdf文档全文双语翻译

  • lasso-security
  • 基于插件的网关,可协调其他MCP,并允许开发人员在IT企业级代理上构建。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • modelscope
  • 开始以更轻松的方式开始构建具有LLM授权的多代理应用程序。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

    Reviews

    3.2 (17)
    Avatar
    user_M7JSM9ow
    2025-04-26

    I've been an avid user of pypsa-mcp by cdgaete and can't recommend it enough! It offers seamless multi-cranial processing capabilities with exceptional precision. The user interface is intuitive, and it supports a wide range of applications. With its robust performance and efficiency, pypsa-mcp stands out as a top-tier tool in its category.

    Avatar
    user_CUsX7lIE
    2025-04-26

    I have been using pypsa-mcp for a while now, and it has genuinely impressed me with its extensive functionalities and seamless integration. The user-friendly interface allows for efficient modeling and simulation of power systems. Kudos to cdgaete for developing such a robust tool that supports advanced analysis with ease. Highly recommend this to anyone in the industry!

    Avatar
    user_F8UGf1Xi
    2025-04-26

    I've been using pypsa-mcp for several projects and I'm thoroughly impressed. The flexibility and functionality provided by cdgaete are unmatched. It's user-friendly, and the community support is excellent. It's become an indispensable tool for my workflow. Highly recommended!

    Avatar
    user_SOTyMXme
    2025-04-26

    The pypsa-mcp is an outstanding tool developed by cdgaete. Its user-friendly interface and powerful capabilities make it an essential resource for optimizing energy systems. The seamless integration with Python ensures efficiency and flexibility in modeling complex scenarios. Highly recommended for anyone in the field!

    Avatar
    user_s0QzYesf
    2025-04-26

    I recently started using pypsa-mcp by cdgaete, and it has significantly improved my workflow. The tools provided are efficient, and the documentation is clear and helpful. I especially appreciate the seamless integration with Python, making it a perfect fit for my projects. Highly recommended for anyone looking to optimize their computational tasks!

    Avatar
    user_GjIDkvrj
    2025-04-26

    As a dedicated user of pypsa-mcp, I am thoroughly impressed with its robust capabilities for multi-core processing in power system analysis. Developed by cdgaete, this tool offers exceptional performance and flexibility, making complex simulations more efficient. Whether you're an academic researcher or industry professional, pypsa-mcp stands out as an essential resource for optimizing your workflow. Highly recommended!

    Avatar
    user_Llg35xtO
    2025-04-26

    As a dedicated user of pypsa-mcp, I can attest to its outstanding functionality. Developed by cdgaete, this tool excels in facilitating power systems analysis with a high degree of precision. Its versatility and user-friendly interface make it an invaluable asset for professionals in the field. I highly recommend pypsa-mcp to anyone in need of reliable power system modeling.

    Avatar
    user_rgwsEdZq
    2025-04-26

    As a loyal user of pypsa-mcp, I highly recommend it for anyone in need of a powerful tool for energy system modeling. This innovative product by cdgaete stands out for its user-friendly interface and robust performance. It’s incredibly efficient and reliable, making complex simulations so much easier and accurate. A must-have tool for professionals in the field!

    Avatar
    user_1SJ1yPSa
    2025-04-26

    As a dedicated user of pypsa-mcp by cdgaete, I must say it has exceeded my expectations. This tool is a game-changer for power system analysis, offering comprehensive and reliable simulations. The robust features and seamless integration enhance my workflow significantly. Highly recommended for professionals in the energy sector!

    Avatar
    user_Iu5gq3vi
    2025-04-26

    As a dedicated user of pypsa-mcp, I can confidently say this tool is a game-changer for power system analysis. Created by cdgaete, pypsa-mcp offers an intuitive interface and robust functionality in power system modeling and optimization. It significantly enhances efficiency and accuracy in my projects. Highly recommended for anyone in the field!

    Avatar
    user_HdP4pmP9
    2025-04-26

    "pypsa-mcp by cdgaete is an exceptional application for managing and controlling power systems. As a dedicated user, I appreciate the robust functionality and user-friendly interface. It offers comprehensive features that are invaluable for both professionals and researchers in the field. Highly recommend it for anyone looking for a reliable and efficient power system management tool!"

    Avatar
    user_qxGuj64z
    2025-04-26

    As an avid user of pypsa-mcp, I am thoroughly impressed with its capabilities. Developed by cdgaete, this tool integrates seamlessly with the Python ecosystem, making complex power system simulations a breeze. Its user-friendly interface and extensive documentation make it accessible to both beginners and advanced users. Highly recommended for anyone in the field of energy system modeling!

    Avatar
    user_CAZ84HPe
    2025-04-26

    I’ve been using pypsa-mcp by cdgaete for a while now, and I must say it’s an outstanding tool for my projects. It’s efficient, reliable, and very user-friendly. The clear interface and robust functionality have significantly improved my workflow. Truly commendable work by the author! Highly recommend it to anyone in need of a comprehensive solution.

    Avatar
    user_r1151Fg6
    2025-04-26

    As a dedicated user of pypsa-mcp, I am thrilled with its robust performance and versatility in optimizing power systems. The tool, crafted by cdgaete, offers seamless integration and a user-friendly interface, making it an essential resource for energy modelers. Whether you're conducting complex simulations or straightforward analyses, pypsa-mcp reliably delivers accurate results, streamlining the entire process. Highly recommended for anyone in the field!

    Avatar
    user_dlVTtL3y
    2025-04-26

    As a loyal user of the pypsa-mcp application, I have found it to be an incredible tool for my projects. Developed by cdgaete, this product stands out with its powerful capabilities and user-friendly interface. It has greatly enhanced my workflow efficiency and has become an indispensable part of my toolkit. Highly recommended for anyone in need of a robust multi-criteria optimization solution!

    Avatar
    user_iYVLHwjy
    2025-04-26

    As a dedicated user of pypsa-mcp by cdgaete, I can confidently say that it's an exceptional tool for energy system modeling and optimization. The seamless integration and robust features have significantly enhanced my workflow. Highly recommended for anyone in the energy systems field!

    Avatar
    user_EhRcGqr4
    2025-04-26

    As an avid user of pypsa-mcp, I am thoroughly impressed with its capabilities. This tool, developed by cdgaete, offers great functionality for managing power system modeling and optimization. Its seamless integration and user-friendly interface make it incredibly efficient for both beginners and professionals. Highly recommend it!