@casys/mcp-fmi 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Casys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,113 @@
1
- # Temporary Holding Version
1
+ # `@casys/mcp-fmi`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Standalone FMI 2.0 Co-Simulation MCP server and Level-2 `@mcpview/compose` Code Mode provider for
4
+ deterministic native-C physics execution.
5
+
6
+ ## Architecture
7
+
8
+ - **Pure TypeScript FMU archive inspector (`inspectFmuArchive`)**: reads `modelDescription.xml`
9
+ directly from any `.fmu` ZIP archive (using Web `DecompressionStream("deflate-raw")`), computes
10
+ the exact archive `fmuSha256`, and verifies typed variable/unit alignment against SysML v2
11
+ attributes (`checkFmiAgainstSysmlAttributes`).
12
+ - **Zero-dependency Python 3 FMI 2.0 runner (`src/runtime/run_fmi2.py`)**: extracts the `.fmu`
13
+ safely, loads `binaries/<platform>/<modelIdentifier>.(dylib|so|dll)` via `ctypes.CDLL`, drives the
14
+ complete FMI 2.0 Co-Simulation C lifecycle (`fmi2Instantiate` -> `fmi2SetupExperiment` ->
15
+ `fmi2EnterInitializationMode` -> `fmi2SetReal` -> `fmi2ExitInitializationMode` -> stepped
16
+ `fmi2DoStep` / `fmi2GetReal` -> `fmi2Terminate` -> `fmi2FreeInstance`), and supports both constant
17
+ inputs and piecewise-constant `inputSchedule` trajectories.
18
+ - **Dual MCP surface (`src/server.ts`)**:
19
+ - Direct MCP tools: `fmi_inspect_fmu`, `fmi_simulate_fmu`
20
+ - Level-2 `@mcpview/compose/code-mode` snippets via `list_snippets` and `run_snippet`:
21
+ `inspect_fmu`, `simulate_fmu`
22
+ - **6-DOF Flight Telemetry Projection**: when simulating a flight-dynamics FMU exporting `posX_m`,
23
+ `posY_m`, `altitude_m`, `pitchDeg`, `rollDeg`, `yawDeg`, and `airspeedMs`, the server
24
+ automatically emits `flightTrack`, effective `flightModel` parameters, and flight qualification
25
+ metrics alongside structural and thermal metrics.
26
+
27
+ ## Literal provenance
28
+
29
+ All simulation results executed against a real compiled `.fmu` emit literal
30
+ `provenance: "verified-solver"`, `engine: "mcp-fmi/fmi2-native"`, and exact `fmuSha256`. When
31
+ `sysmlAttributes` is omitted, `fmiContractStatus` stays literally `"unverified"` — never relabelled
32
+ as `"compatible"`.
33
+
34
+ ## Quick start
35
+
36
+ ### Build the reference native FMUs
37
+
38
+ ```bash
39
+ deno task build:examples
40
+ ```
41
+
42
+ This compiles three zero-dependency C FMI 2.0 Co-Simulation `.fmu` archives into gitignored
43
+ `state/local/fmu/`:
44
+
45
+ - `state/local/fmu/ThermalCantileverHook.fmu` (`examples/thermal-cantilever-hook/`)
46
+ - `state/local/fmu/JetDroneX1.fmu` (`examples/jet-drone-6dof/`)
47
+ - `state/local/fmu/MicroTurbojetBrayton.fmu` (`examples/micro-turbojet-brayton/`)
48
+
49
+ ### Run over stdio
50
+
51
+ ```bash
52
+ deno task serve:stdio
53
+ ```
54
+
55
+ ### Run over HTTP (`POST /mcp`, `GET /health`)
56
+
57
+ ```bash
58
+ deno task serve
59
+ # Optional Bearer authentication on /mcp:
60
+ MCP_BEARER_TOKEN=secret-token deno task serve
61
+ ```
62
+
63
+ ### Run with Docker
64
+
65
+ ```bash
66
+ docker build -t casys/mcp-fmi:0.1.0 .
67
+ docker run --rm -p 3025:3025 -e MCP_BEARER_TOKEN=secret-token casys/mcp-fmi:0.1.0
68
+ ```
69
+
70
+ ## Widgets (MCP Apps)
71
+
72
+ Results are shown as small, individual MCP App widgets, one reading each, never a dashboard. Each
73
+ widget is its own `ui://mcp-fmi/<widget>` resource and adapts to the width its host grants (a
74
+ Compose board snaps its resize handle between `supportedWidths`; a standalone host gets the widest).
75
+
76
+ | Widget (`ui://mcp-fmi/…`) | Kind | Shows | `supportedWidths` |
77
+ | ------------------------- | ----- | ----------------------------------------------------------------------------- | ----------------- |
78
+ | `fmu-verdict` | stat | PASS/FAIL of the simulation limits (or of the SysML contract), 1 to 3 numbers | 280, 380, 520 |
79
+ | `fmu-time-series` | chart | Main signal over time (temperature, or altitude for flight FMUs) vs its limit | 320, 460, 660 |
80
+ | `fmu-variables` | table | Final values of a simulation, or the variables of an inspected FMU | 340, 480, 680 |
81
+ | `fmu-checks` | table | Limit checks of a simulation, or SysML unit bindings of an inspected FMU | 340, 480, 680 |
82
+
83
+ Smallest width: the essential. Middle: the usual reading. Largest: the full detail of that one
84
+ thing, with a small provenance footer (engine, FMU and modelDescription.xml SHA-256, run window).
85
+ The verdict stat never carries a check matrix: that is the `fmu-checks` table. `fmi_inspect_fmu`,
86
+ `fmi_simulate_fmu` and `run_snippet` advertise `fmu-verdict` by default; a board selects another
87
+ widget for the same result by resource URI. Every successful `run_snippet` result also lists all the
88
+ widgets able to render it in `_meta["io.mcpview/views"]` (`name`, `resourceUri`, `title`,
89
+ `supportedWidths`), so a Code Mode program can show one receipt in several widgets with
90
+ `api.panel(receipt.id, { view: "fmu-checks" })`. `FMI_WIDGETS` (exported from `mod.ts`) lists URIs,
91
+ kinds and `supportedWidths` for a board to read:
92
+
93
+ ```ts
94
+ import { FMI_WIDGETS } from "jsr:@casys/mcp-fmi";
95
+ // { resourceUri: widget.uri, supportedWidths: widget.supportedWidths }
96
+ ```
97
+
98
+ Rebuild the committed single-file HTML with `deno task build:ui` (bundles against the published
99
+ `@mcpview/components`); `deno task check:ui:bundle` fails when a bundle is stale.
100
+
101
+ ## Level-2 Code Mode snippets
102
+
103
+ Connect `@casys/mcp-fmi` to any `@mcpview/compose/code-mode` host using `connectSnippetProviders`:
104
+
105
+ - `inspect_fmu`: `{ fmuPath, sysmlAttributes? }`
106
+ - `simulate_fmu`:
107
+ `{ fmuPath, parameters?, inputs?, inputSchedule?, outputs?, startTime?, stopTime?, stepSize?, sysmlAttributes?, partName?, maxDisplacementLimitMm?, maxStressLimitMPa?, maxTempLimitC?, minThrustToWeight?, minAltitudeLimitM?, minEnduranceLimitMin? }`
108
+
109
+ ## Verification
110
+
111
+ ```bash
112
+ deno task release:check
113
+ ```