Repository avatar
Other Tools
v0.1.0
active

calcscript

io.github.CloudCorpRecords/calcscript

Engineering calculators for oil and gas: thermo, flow, pipes, valves, heat exchangers, economics.

Documentation

calcscript

Engineering calculators for oil and gas: thermo, flow, pipes, valves, heat exchangers, economics. calcscript is a local forwarding client for the hosted MCP service at engscript.com: it answers tools/list on your own machine from the captured tool definitions and forwards every call to the service, returning the answers exactly as they come back.

The tools

  • MIXTURE — Primary thermodynamic property calculator. Required: HC, mole, P, T.
  • CARBON — Calculate thermodynamic properties of hydrocarbon mixture. Required: HC, mole, P, T.
  • STEAM — Calculate thermodynamic and transport properties of steam based on IAPWS Required: P, T.
  • PSYCHROMETRIC — Psychrometric properties of moist air Required: BP, DB.
  • FUELGAS — Calculate MW, LHV and HHV of fuel gas from composition Required: HC, mole.
  • FLUEGAS — Calculate enthalpy of flue gas from composition Required: HC, mole, Tb, Tg.
  • EMISSIONFACTOR — Calculate CO2 emission conversion factor from gas composition Required: HC, mole.
  • REFRIGERANT — Calculate refrigerant thermodynamic properties using CoolProp. Required: Fluid.
  • PTV — Calculate gas molar volume using equation of state Required: P, T.
  • MtoV — Convert mass flow rate to volumetric flow rate at standard condition Required: M, MW.
  • VtoM — Convert volumetric flow rate to mass flow rate at standard condition and normal condition Sm3/hr, Nm3/hr, SCFH Required: V, MW.
  • Pmean — Calculate mean pressure between inlet and outlet Required: Fluid, P1, P2.
  • PIPEFF — Calculate Darcy friction factor based on Reynolds number and pipe roughness Required: Piping, D, Re.
  • STEAMLEAK — Calculate steam leak mass flow and flow condition (CHOKED / SUBCRITICAL) based on upstream and downstream conditions Required: P1, P2, T1, T2, h.
  • STEAMPH — Calculate mass flow from pin-hole on the steam piping Required: P, T, h.
  • PIPEINSUL — Calculate optimal pipe insulation thickness to limit outer surface temperature (burn protection) and minimise heat loss. Required: NPS, Tf, Ta, Tmax, kins, ha.
  • PIPESTEAM — Calculate steam pipe sizing: pipe diameter, velocity, pressure drop Required: P, T, M, L.
  • PIPEWATER — Calculate water pipe sizing: pipe diameter, velocity, pressure drop Required: P, T, M, L.
  • PIPEAIR — Calculate compressed air pipe sizing: pipe diameter, velocity, pressure drop Required: P, T, M, L.
  • PIPENITROGEN — Calculate nitrogen pipe sizing: pipe diameter, velocity, pressure drop Required: P, T, M, L.
  • PIPEFLOWGAS — Calculate isothermal gas pipe flow: density, volumetric flow rate, mass flow rate from pressure drop Required: P1, P2, T, L, D, MW.
  • PIPEFLOWLIQ — Calculate liquid pipe flow: volumetric flow rate and mass flow rate from pressure drop Required: P1, P2, L, D, rho.
  • CVGAS — Calculate gas control valve Cv and Kv from flow conditions Required: Q, P1, P2, T1, MW, k.
  • CVLIQ — Calculate liquid control valve Cv and Kv from flow conditions Required: Q, P1, P2, rho.
  • CVSTEAM — Calculate steam control valve Cv and Kv from flow conditions Required: M, P1, P2, rho.
  • ORIFICEGAS — Gas orifice sizing / differential pressure / flow rate calculation based on ISO 5167 orifice. Required: M, dP, D2, P1, D1, rho, mu.
  • ORIFICELIQ — Liquid orifice sizing / differential pressure / flow rate calculation based on ISO 5167 orifice. Required: M, dP, D2, P1, D1, rho, mu.
  • VENTURIGAS — Gas Venturi tube sizing / differential pressure / flow rate calculation based on ISO 5167 Venturi meter (as cast convergent venturi tube). Required: M, dP, D2, P1, D1, rho, mu.
  • VENTURILIQ — Liquid Venturi tube sizing / differential pressure / flow rate calculation based on ISO 5167 Venturi meter (as cast convergent venturi tube). Required: M, dP, D2, P1, D1, rho, mu.
  • PSVGAS — Calculate required PSV (pressure safety valve) relief area for gas/vapor service per API 520 Required: M, P1, P2, T1, MW.
  • PSVSTEAM — Calculate required PSV (pressure safety valve) relief area for steam service per API 520 Required: M, P1, T1.
  • PSVLIQ — Calculate required PSV (pressure safety valve) relief area for liquid service per API 520 Required: M, P1, P2, rho.
  • PUMPBHP — Calculate pump brake horsepower Required: rho, Q, P1, P2, Eff.
  • COMPPOLYEFF — Calculate polytropic efficiency of compressor Required: Pi, Po, Ti, To, k.
  • TBNEFF — Calculate steam turbine isentropic efficiency Required: Pi, Ti, Po, To.
  • STGEFF — Calculate multistage steam turbine isentropic efficiency Required: M1, P1, T1, P2, T2, E.
  • HTRINOUTEFF — Calculate fired heater heat duty and efficiency from inlet/outlet conditions and composition Required: HC, mole, Mfuel, Tfuel, Tair, exO2, Trad, Tstk.
  • HTRLOSSEFF — Calculate fired heater loss efficiency from ambient temperature, stack gas temperature and excess oxygen Required: Type, Tg, Ta, exO2.
  • HEXRF — Heat exchanger fouling resistance back-calculation from shell/tube-side operating conditions. Required: Unknown, D_shll, D_tube, D_wall, P_tube, S_baffle, N_tube, L_tube, N_shllseri, N_shllpara, N_shllpass, N_tubepass, A_hex, R_shll, R_tube, F, k_hex, T_shll, rho_shll, Cp_shll, mu_shll, k_shll, T_tube, rho_tube, Cp_tube, mu_tube, k_tube, V_shll, T1_shll, T2_shll, V_tube, T1_tube, T2_tube.
  • LMTD — Calculate LMTD of heat exchanger Required: Thi, Tho, Tci, Tco.
  • STEAMFLASH — Calculate flash steam flow from pressure reduction Required: Mc, Pc, Ps.
  • DESUPERHEATER — Calculate boiler feed water flow and total flow from pressure and temperature reduction through desuperheater. Required: Min, Pin, Tin, Pout, Tout, Pbfw, Tbfw.
  • HPADEPRESS — Calculate depressurization gas volume and hold time for high pressure air storage vessel Required: V1, P1, P2, Q2.
  • GN2DEPRESS — Calculate depressurization gas volume and hold time for gaseous nitrogen storage vessel Required: V1, P1, P2, Q2.
  • LN2DEPRESS — Calculate depressurization gas volumn abd hold time and saturation temperature for liquid nitrogen storage vessel Required: V1, P1, P2, Q2.
  • STMDEPRESS — Calculate depressurization steam volumn and hold time for steam accumulator Required: V1, P1, P2, M2.
  • CTWREVAPOR — Cooling tower evaporation rate: mass removal rate (MR) and heat removal rate (QR) Required: INPUT.
  • CTWRLG — Cooling tower L/G ratio calculation Required: INPUT.
  • CTWRNTU — Cooling tower NTU and characteristic C value calculation Required: INPUT.
  • CTWRCAPA — Cooling tower capacity evaluation Required: INPUT.
  • CTWRCAPADSNTST — Cooling tower capacity evaluation: design vs test Required: INPUT.
  • DVR — Data Validation and Reconciliation Required: MEASURED, ACCURACY, EQUATION.
  • advDVR — Advanced Data Validation and Reconciliation including gross error detection and elimation Required: MEASURED, ACCURACY, EQUATION.
  • BALANCE — General mass/energy balance solver using GEKKO Required: VARIABLE, EQUATION.
  • PINCHMANUAL — Pinch analysis (minimum utilities, pinch temperatures, composite curves, grand composite curve) and heat exchanger network design by manual tick-off heuristic Required: INPUT.
  • PINCHSOLVER — Pinch analysis (minimum utilities, pinch temperatures, composite curves, grand composite curve) and heat exchanger network design by optimization solver Required: INPUT.
  • FORMULA — Generic formula calculator with unit conversion and IF-THEN-ELSE Required: INPUT, FORMULA, OUTPUT.
  • SOLVE — Solve nonlinear equations with unknown variables using fsolve Required: INPUT, FORMULA, OUTPUT.
  • ECONOMIC — Economic analysis: NPV, IRR, Simple Payback, Profitability Index, EAC Required: CF.
  • advECONOMIC — Advanced Economic analysis with inflation, depreciation, and tax: NPV, IRR, Simple Payback, Profitability Index, NCF Required: INPUT.

Install and run

As an MCP server via npm:

npx -y @reneturcios/calcscript mcp

MCP client configuration:

{
  "mcpServers": {
    "calcscript": {
      "command": "npx",
      "args": ["-y", "@reneturcios/calcscript", "mcp"]
    }
  }
}

As a container:

docker run -i ghcr.io/cloudcorprecords/calcscript
docker run --rm ghcr.io/cloudcorprecords/calcscript MIXTURE '<json-args>'

CLI

One binary serves both the command line and the MCP server. Each tool is a subcommand taking a single JSON string with that tool's arguments:

calcscript MIXTURE '{"HC":["a","b"],"mole":[1,2],"P":{},"T":{}}'
calcscript CARBON '{"HC":["a","b"],"mole":[1,2],"P":{},"T":{}}'
calcscript --version

Exit codes: 0 when the forwarded call succeeds, 1 when the upstream result is an error, and 2 for usage problems such as an unknown subcommand or a malformed JSON argument.

Configuration

  • CALCSCRIPT_MCP_URL — Overrides the upstream endpoint. The default is the pinned hosted endpoint, https://engscript.com/mcp. (The override variable is a reconstruction added by this rebuild.)

The upstream registry record declares no headers on its remote, so calcscript sends no authentication header of any kind — the calls are keyless.

Upstream failures — a JSON-RPC error from the service, a non-2xx response, an unreadable body, or a request that fails outright — are reported to the caller as an error result whose text starts with calcscript error:.

How forwarding works

The first forwarded call opens a session: an initialize request (protocol version 2025-03-26), followed by a notifications/initialized notification, then the tools/call itself. If the service answers the initialize request with an Mcp-Session-Id header, that value is carried on every later request, and the open session is reused for the rest of the process. Replies are accepted either as plain JSON or as server-sent events. Successful results pass through verbatim, including any isError flag and any extra fields the service includes. The full captured surface is 60 tools.

Development

npm install
npm run build   # tsc -> dist/ (dist/cli.js is the bin)
npm test        # tsx --test test/*.test.ts — stubbed upstream, no network
npm run dev     # run the CLI from source

The test suite checks the served tool list against the captured fixture, exercises the session handshake and its reuse, asserts that no Authorization header is sent under any environment, and verifies that arguments go upstream untouched and results come back untouched.

License

MIT — see LICENSE. Copyright (c) 2026 Rene Turcios.

NPM
@reneturcios/calcscript
Install Command
npm install @reneturcios/calcscript
Runtime: npx
OCI
ghcr.io/cloudcorprecords/calcscript:0.1.0
Install Command
docker pull ghcr.io/cloudcorprecords/calcscript:0.1.0:undefined
Runtime: docker