battery-erp
Battery ERP — 材料、电芯、电池包及供应链管理,支持实时
大宗商品定价和 Fabric Lakehouse 分析。
覆盖完整的电池价值链:锂、钴、镍、锰、石墨
到电芯化学体系(NMC-811、NCA、LFP、LMO),再到带 BOM 成本核算的电池包、
供应商评分、库存管理和假设成本场景。
mcp-name: io.github.icohangar-ops/battery-erp
这是什么
Battery ERP 管理完整的电池价值链——从原材料采购到电芯制造再到电池包组装。每项成本都可追溯到具体的材料、供应商和价格点。
层级 | 作用 |
数据模型 | RawMaterial、CellChemistry、BatteryCell、BatteryPack、BOMItem、Supplier、InventoryRecord、PurchaseOrder、ManufacturingBatch |
业务规则 | BOM 成本汇总、库存状态管理、供应商评分(A-D 综合等级)、制造良率跟踪、价格趋势分析、假设成本场景 |
定价引擎 | 默认材料价格表(20+ 种材料)、AlphaVantage 实时大宗商品价格集成、FRED 宏观数据叠加 |
分析 | 库存健康报告、供应链报告、制造良率报告、化学体系成本对比仪表盘 |
Fabric Lakehouse | 11 张 Delta 表,用于持久化存储和 SQL 分析 |
Related MCP server: foundry net-industrial
快速开始
# From PyPI — https://pypi.org/project/battery-erp/
python3 -m pip install 'battery-erp[mcp]' # MCP tools
python3 -m pip install 'battery-erp[api]' # REST adapter
# From source
git clone https://github.com/icohangar-ops/battery-erp.git
cd battery-erp
python3 -m pip install -e '.[dev]'
PYTHONPATH=src python3 -m pytest tests/ -v
# Domain modules
python3 -c "
from battery_erp.pricing import calculate_cell_cost_summary, get_material_price_table
prices = get_material_price_table()
for chem in ['NMC-811', 'NMC-622', 'NCA', 'LFP', 'LMO']:
r = calculate_cell_cost_summary(chem, 50.0, prices)
print(f'{chem}: \${r[\"cost_per_kwh\"]:.1f}/kWh (BOM: \${r[\"bom_cost_usd\"]:.2f})')
"架构
┌──────────────────────────────────────┐
│ Raw Materials (20+ tracked) │
│ Lithium · Cobalt · Nickel · Mn · Gr │
└──────────────┬───────────────────────┘
│ BOM
┌──────────────▼───────────────────────┐
│ Cell Chemistries │
│ NMC-811 · NMC-622 · NCA · LFP · LMO │
└──────────────┬───────────────────────┘
│ cells + components
┌──────────────▼───────────────────────┐
│ Battery Packs │
│ EV · ESS · Consumer · Industrial │
└──────────────────────────────────────┘
Side modules:
┌─────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Supplier Scoring │ │ Inventory Mgmt │ │ Cost Scenarios │
│ Composite 0-100 │ │ Reorder logic │ │ What-if analysis │
│ A/B/C/D grades │ │ Status tracking │ │ Price shock model │
└─────────────────┘ └──────────────────┘ └──────────────────┘核心模块
battery_erp.core.models
所有领域数据类:
RawMaterial— 材料目录,含定价、HS 编码、危险品信息CellChemistry— NMC-111/622/811、NCA、LFP、LMO,含能量密度和循环寿命BatteryCell— 电芯规格(容量、电压、外形尺寸、重量)BatteryPack— 电池包组装(电芯 + BMS + 热管理)BOMItem— 物料清单行项目,含损耗系数Supplier— 供应商目录,含质量评级、交货周期、认证InventoryRecord— 仓库库位,含补货逻辑PurchaseOrder— 采购订单生命周期跟踪ManufacturingBatch— 生产批次良率跟踪PriceHistory— 大宗商品价格时间序列
battery_erp.core.rules
确定性业务规则:
rollup_bom_cost()— 总 BOM 成本,含材料明细和损耗成本calculate_cell_bom()— 为任意化学体系生成代表性 BOMcalculate_pack_bom()— 电池包级 BOM(电芯 + 外壳 + BMS + 冷却)update_inventory_status()— 重新计算 in_stock/low/out_of_stockcheck_reorder_suggestions()— 生成采购订单建议calculate_batch_metrics()— 汇总制造良率analyze_price_history()— 价格趋势分析,含波动率estimate_cell_cost_impact()— 假设成本场景建模calculate_pack_metrics()— 电池包能量密度和效率
battery_erp.supply_chain
供应链管理:
score_supplier()— 综合评分(质量 35%、准时交付 35%、交货周期 20%、认证 10%)rank_suppliers()— 按评分排序,按材料筛选create_purchase_order()— 根据供应商数据创建采购订单analyze_po_pipeline()— 采购订单管道分析(逾期检测、交货周期跟踪)suggest_dual_sourcing()— 双源采购策略建议
battery_erp.pricing
大宗商品定价:
get_material_price_table()— 20+ 种电池材料的默认价格calculate_cell_cost_summary()— 各化学体系的快速成本估算update_prices_from_alpha_vantage()— 实时大宗商品价格获取update_prices_from_fred()— 宏观经济指标
battery_erp.analytics
报表:
generate_inventory_report()— 完整库存健康仪表盘generate_supply_chain_report()— 供应商 + 采购订单管道报表generate_manufacturing_report()— 良率指标generate_pricing_report()— 化学体系成本对比 + 价格趋势
化学体系成本对比(默认价格,50Ah 电芯)
化学体系 | BOM 成本 | $/kWh | 正极占比 % | 关键特性 |
LFP | 最低 | ~$50-55 | ~35% | 无钴/镍,超安全,4000+ 次循环 |
LMO | 低 | ~$55-60 | ~40% | 低成本,电动工具 |
NMC-111 | 中等 | ~$70-80 | ~50% | 均衡,成熟 |
NMC-622 | 中等 | ~$75-85 | ~48% | 能量与成本平衡良好 |
NMC-811 | 较高 | ~$80-90 | ~52% | 高能量密度,EV 主导 |
NCA | 最高 | ~$85-95 | ~55% | 特斯拉旗舰,270 Wh/kg |
Microsoft Fabric 集成
Fabric 笔记本
笔记本 | 用途 |
| 创建全部 11 张 Delta 表并写入种子数据 |
| 完整成本分析仪表盘(化学体系对比、电池包成本核算、库存、供应商、价格趋势、场景) |
Delta 表结构
表 | 关键列 |
| material_id、name、category、unit_price_usd、price_source、hs_code |
| chemistry_id、name、cathode_type、energy_density_wh_per_kg、cycle_life |
| cell_id、sku、chemistry、form_factor、nominal_capacity_ah、energy_wh、weight_kg |
| pack_id、sku、cell_sku、total_cells、nominal_capacity_kwh、pack_weight_kg |
| bom_id、parent_sku、material_name、quantity_per_unit、unit_cost_usd、waste_factor_pct |
| supplier_id、name、country、materials_supplied、quality_rating、lead_time_days |
| record_id、sku、material_name、quantity_on_hand、quantity_reserved、reorder_point |
| po_id、po_number、supplier_name、quantity、total_usd、status、expected_delivery |
| material_name、price_usd、as_of、source |
| batch_id、product_sku、chemistry、quantity_produced、quantity_pass、yield_pct |
| scenario_id、scenario_name、material_name、current_price_usd、scenario_price_usd、pct_change |
Fabric 快速开始
运行
fabric_setup_lakehouse.py创建全部 11 张 Delta 表运行
fabric_cost_dashboard.py获取完整分析仪表盘仪表盘涵盖:化学体系成本对比、电池包级成本核算、库存健康、供应商记分卡、价格趋势、制造良率、成本场景
库存适配器(REST + MCP)
Battery ERP 是一个领域库,而非托管的 ERP。对于 SMS / 文本行和
代理工作流,共享的 InventoryService 同时位于轻量 REST API 和
MCP 服务器之下。完整详情:docs/INTEGRATION.md。
SMS / ClickSend Cursor / Claude (stdio MCP)
│ │
▼ ▼
REST API (port 8088) battery_erp.mcp
└──────────┬──────────────┘
▼
InventoryService
▼
InMemoryInventoryStore (demo)
▼
Human bin confirmation不要在浏览器中调用 MCP。请将 REST 和 MCP 放在不同的终端中。
安装(macOS / zsh)
使用 python3。给 pip extras 加引号,以免 zsh 将其通配展开:
cd ~/Desktop/icohangar-repos/battery-erp
python3 -m pip install -e '.[dev]' # api + mcp + pytest终端 A — REST(文本行后端)
cd ~/Desktop/icohangar-repos/battery-erp
export BATTERY_ERP_CONFIRM_TOKEN=dev-secret
export BATTERY_ERP_AUDIT_LOG=/tmp/battery-erp-audit.jsonl
PYTHONPATH=src python3 -m battery_erp.api
# Uvicorn → http://127.0.0.1:8088curl -s http://127.0.0.1:8088/health
curl -s http://127.0.0.1:8088/inventory/lookup/lithium终端 B — MCP(仅限代理 / Cursor)
保持终端 A 运行。在新终端中:
cd ~/Desktop/icohangar-repos/battery-erp
export BATTERY_ERP_CONFIRM_TOKEN=dev-secret
PYTHONPATH=src python3 -m battery_erp.mcp该进程在 stdio 上保持静默——这对 MCP 主机来说是正常的。不要将其粘贴到 API 终端中。
Cursor MCP 配置
添加到 ~/.cursor/mcp.json(使用绝对路径;用 python3 而非 python):
{
"mcpServers": {
"battery-erp": {
"command": "python3",
"args": ["-m", "battery_erp.mcp"],
"env": {
"PYTHONPATH": "/Users/YOU/Desktop/icohangar-repos/battery-erp/src",
"BATTERY_ERP_CONFIRM_TOKEN": "replace-me",
"BATTERY_ERP_AUDIT_LOG": "/tmp/battery-erp-audit.jsonl"
}
}
}
}然后在 Cursor 中重新加载 MCP 服务器。暴露的工具:lookup_inventory、
get_inventory_status、get_inventory_record、list_inventory、
create_bin_check_request、record_bin_confirmation。
表面 | 入口 | 共享层 |
REST |
|
|
MCP | 上述工具(mcp SDK 2.x | 相同 |
变更性的 bin 确认需要 BATTERY_ERP_CONFIRM_TOKEN,并可选择性地
将 JSONL 审计日志写入 BATTERY_ERP_AUDIT_LOG。
目录 / 注册表打包:参见 PUBLISH.md(glama.json、
Dockerfile、server.json)。合并到 main 后,在 Glama 上以
@icohangar-ops/battery-erp 认领。
测试
PYTHONPATH=src python3 -m pytest tests/ -v
# Domain tests + inventory service / REST / MCP scaffold使用场景
电芯制造商 — 跨化学体系的 BOM 成本跟踪、良率优化
电池包集成商 — 电池包级成本估算、供应商选择
采购部门 — 供应商评分、双源采购、采购订单管道管理
财务部门 — 大宗商品价格风险、假设场景、库存估值
高管层 — 展示 $/kWh 趋势、供应链韧性、降本机会的仪表盘
许可证
MIT。参见 LICENSE。
CHP 治理
本仓库已通过 共识加固协议(CHP) 加固,这是 Cubiczan 为多代理 AI 系统设计的决策治理层。
协议层级
R0 门控:所有决策必须通过 Solvable、Scoped、Valid、Worth_it 检查
基础披露:1-3 个最薄弱假设、1-2 个失效条件、1 个关键漏洞
对抗层:在阶段 0 和第 3 轮强制进行魔鬼代言人审查
状态机:EXPLORING → PROVISIONAL → PROVISIONAL_LOCK → LOCKED
第三方验证:锁定前需独立 CONFIRM/REJECT
领域配置
类别:采矿 / 供应链
基础阈值:75
CFO 准确性防护:已禁用
合规工件
文件 | 用途 |
| 决策状态转换 |
| 领域校准阈值 |
| 标准化挑战模板 |
| 合规跟踪与审计轨迹 |
CHP 版本
cognitive-mesh-orchestrator 0.1.0 | 协议文档
演示
手持设备 — 零件箱文本行
来自实时线索页面的移动端采集 (parts-bin-text-line--icohangar.replit.app)。 短信 → 文本行 → 电池ERP库存检查 → 人工料箱确认。
Available Tools
6 toolscreate_bin_check_requestC
Create a human bin-count verification task for SMS / warehouse workflows.
Inputs: part_number (required), notes.
get_inventory_recordB
Return the full inventory record for a SKU (on-hand, reserved, reorder, cost).
Inputs: sku (required).
get_inventory_statusC
Get inventory status plus reorder suggestion when below reorder point.
Inputs: part_number (required).
list_inventoryB
List status for all seeded inventory SKUs (demo store).
Inputs: no named parameters.
lookup_inventoryB
Look up available quantity and stock status for a part number or SKU.
Inputs: part_number (required).
record_bin_confirmationC
Record a human-confirmed on-hand quantity. Requires auth_token matching BATTERY_ERP_CONFIRM_TOKEN.
Inputs: auth_token (required), part_number (required), actual_quantity (required), actor, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
lookup_inventory, get_inventory_status, and get_inventory_record all take a SKU and return overlapping inventory quantities/status, so their boundaries are unclear. list_inventory and the two bin-check tools are distinct, but the three inventory getters could easily be misselected.
All names are snake_case and verb-led, with read operations using lookup/get/list and write operations using create/record. The pattern is mostly predictable, with only a minor inconsistency between lookup_inventory and the get_inventory_* family.
Six tools is a well-scoped set for a focused inventory ERP demo: four query variants plus two bin-count workflow actions. Each tool has a reasonable role, and the count is neither bloated nor too thin.
The set covers inventory queries and the bin-confirmation workflow, but lacks lifecycle operations such as SKU creation/update or any way to list pending bin-check requests. Reorder suggestions are generated but there is no tool to act on them, creating a dead end.
Related MCP Connectors
Supply chain operations: dock scheduling, check-in, doors, inventory, orders and freight.
Warehouse digital twin: what-if simulation and AI optimisation of slotting, batching and labour.
Real-time supply chain risk intelligence — 24 tools, proprietary indices, predictive signals
Cross-OEM industrial machine intelligence: identity, normalization, automation, attestation.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA custom implementation for real-time supply chain optimization that enables parallel tool calling to provide intelligent inventory management recommendations and actionable insights in response to live supply chain events.6-
- FlicenseAqualityBmaintenanceCross-OEM industrial machine intelligence. Normalizes telemetry across 16 manufacturer families (Fanuc, Siemens, Haas, DMG Mori, Mazak), enables plain-English operational automation, and produces tamper-evident work records. 14 MCP tools.14-
- FlicenseNot gradedqualityBmaintenanceAn AI-powered EV Digital Twin platform for battery health monitoring, predictive maintenance, fleet analytics, and intelligent decision support using MCP tools for SOH prediction and RUL estimation.6-
- FlicenseNot gradedqualityCmaintenanceEnables supply chain management tasks such as tracking shipments, managing inventory, and supplier scorecards through MCP protocol.24 PyPI-