@casys/mcp-fmi 0.1.2 → 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/mcp-fmi.mjs CHANGED
@@ -54381,7 +54381,7 @@ var McpApp = class {
54381
54381
  continue;
54382
54382
  }
54383
54383
  const resourceUri = `ui://${config2.prefix}/${viewerName}`;
54384
- const readFile4 = config2.readFile;
54384
+ const readFile5 = config2.readFile;
54385
54385
  const currentDistPath = distPath;
54386
54386
  this.registerResource({
54387
54387
  uri: resourceUri,
@@ -54389,7 +54389,7 @@ var McpApp = class {
54389
54389
  description: `MCP App: ${viewerName}`,
54390
54390
  mimeType: MCP_APP_MIME_TYPE
54391
54391
  }, async () => {
54392
- const html = await Promise.resolve(readFile4(currentDistPath));
54392
+ const html = await Promise.resolve(readFile5(currentDistPath));
54393
54393
  const content = {
54394
54394
  uri: resourceUri,
54395
54395
  mimeType: MCP_APP_MIME_TYPE,
@@ -56497,9 +56497,103 @@ async function runFmi2Simulation(request) {
56497
56497
  };
56498
56498
  }
56499
56499
 
56500
+ // src/viewer.ts
56501
+ import { readFile as readFile4 } from "node:fs/promises";
56502
+ import { statSync } from "node:fs";
56503
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
56504
+
56505
+ // src/widgets.ts
56506
+ var FMU_VERDICT_WIDGET = {
56507
+ key: "fmu-verdict",
56508
+ uri: "ui://mcp-fmi/fmu-verdict",
56509
+ kind: "stat",
56510
+ title: "FMU verdict",
56511
+ description: "PASS or FAIL of the simulation limits (or of the SysML contract) with its headline numbers.",
56512
+ supportedWidths: [280, 380, 520]
56513
+ };
56514
+ var FMU_TIME_SERIES_WIDGET = {
56515
+ key: "fmu-time-series",
56516
+ uri: "ui://mcp-fmi/fmu-time-series",
56517
+ kind: "chart",
56518
+ title: "FMU time series",
56519
+ description: "The main signal of the simulation over time, against its limit.",
56520
+ supportedWidths: [320, 460, 660]
56521
+ };
56522
+ var FMU_VARIABLES_WIDGET = {
56523
+ key: "fmu-variables",
56524
+ uri: "ui://mcp-fmi/fmu-variables",
56525
+ kind: "table",
56526
+ title: "FMU variables",
56527
+ description: "Final values of a simulation, or the variables of an inspected FMU.",
56528
+ supportedWidths: [340, 480, 680]
56529
+ };
56530
+ var FMU_CHECKS_WIDGET = {
56531
+ key: "fmu-checks",
56532
+ uri: "ui://mcp-fmi/fmu-checks",
56533
+ kind: "table",
56534
+ title: "FMU checks",
56535
+ description: "The limit checks of a simulation, or the SysML unit bindings of an inspected FMU.",
56536
+ supportedWidths: [340, 480, 680]
56537
+ };
56538
+ var FMI_WIDGETS = [
56539
+ FMU_VERDICT_WIDGET,
56540
+ FMU_TIME_SERIES_WIDGET,
56541
+ FMU_VARIABLES_WIDGET,
56542
+ FMU_CHECKS_WIDGET
56543
+ ];
56544
+ var FMI_DEFAULT_WIDGET = FMU_VERDICT_WIDGET;
56545
+ function fmiWidgetByKey(key) {
56546
+ return FMI_WIDGETS.find((widget) => widget.key === key);
56547
+ }
56548
+ var FMI_VIEWS_META_KEY = "io.mcpview/views";
56549
+ function fmiDeclaredViews(registered = FMI_WIDGETS.map((widget) => widget.key)) {
56550
+ return FMI_WIDGETS.filter((widget) => registered.includes(widget.key)).map((widget) => ({
56551
+ name: widget.key,
56552
+ resourceUri: widget.uri,
56553
+ title: widget.title,
56554
+ supportedWidths: widget.supportedWidths
56555
+ }));
56556
+ }
56557
+
56558
+ // src/viewer.ts
56559
+ var DENO_RELATIVE = `./ui/dist/${FMI_WIDGETS[0].key}/index.html`;
56560
+ function isRemote(path) {
56561
+ return path.startsWith("https://") || path.startsWith("http://");
56562
+ }
56563
+ function isFile(path) {
56564
+ try {
56565
+ return statSync(path).isFile();
56566
+ } catch {
56567
+ return false;
56568
+ }
56569
+ }
56570
+ function viewerModuleUrl(moduleUrl = import.meta.url) {
56571
+ const denoLayout = isRemote(moduleUrl) || isFile(fileURLToPath2(new URL(DENO_RELATIVE, moduleUrl)));
56572
+ return denoLayout ? new URL("../server.ts", moduleUrl).href : moduleUrl;
56573
+ }
56574
+ function registerFmiWidgets(app, moduleUrl = viewerModuleUrl()) {
56575
+ return app.registerViewers({
56576
+ prefix: "mcp-fmi",
56577
+ viewers: FMI_WIDGETS.map((widget) => widget.key),
56578
+ moduleUrl,
56579
+ exists: (path) => isRemote(path) || isFile(path),
56580
+ readFile: async (path) => {
56581
+ if (!isRemote(path)) return await readFile4(path, "utf8");
56582
+ const response = await fetch(path);
56583
+ if (!response.ok) {
56584
+ throw new Error(
56585
+ `Unable to fetch FMI widget from ${path}: HTTP ${response.status}.`
56586
+ );
56587
+ }
56588
+ return await response.text();
56589
+ },
56590
+ humanName: (name) => `FMI ${fmiWidgetByKey(name)?.title.toLowerCase() ?? name}`
56591
+ });
56592
+ }
56593
+
56500
56594
  // src/server.ts
56501
56595
  var MCP_FMI_ENGINE_ID = "mcp-fmi/fmi2-native";
56502
- var MCP_FMI_VERSION = "0.1.2";
56596
+ var MCP_FMI_VERSION = "0.2.0";
56503
56597
  var FLIGHT_REQUIRED_OUTPUTS = [
56504
56598
  "posX_m",
56505
56599
  "posY_m",
@@ -57198,11 +57292,17 @@ function createMcpFmiServer(options = {}) {
57198
57292
  "Use `fmi_inspect_fmu` / `fmi_simulate_fmu` or Level-2 snippets `inspect_fmu` / `simulate_fmu` via `list_snippets` and `run_snippet`."
57199
57293
  ].join(" ")
57200
57294
  });
57295
+ const registeredWidgets = registerFmiWidgets(app, options.viewerModuleUrl).registered.filter((key) => FMI_WIDGETS.some((widget) => widget.key === key));
57296
+ const hasDefaultWidget = registeredWidgets.includes(FMI_DEFAULT_WIDGET.key);
57297
+ const declaredViews = fmiDeclaredViews(registeredWidgets);
57298
+ const viewsMeta = declaredViews.length > 0 ? { [FMI_VIEWS_META_KEY]: declaredViews } : {};
57299
+ const viewerMeta = hasDefaultWidget ? { _meta: { ui: { resourceUri: FMI_DEFAULT_WIDGET.uri } } } : {};
57201
57300
  app.registerTool(
57202
57301
  {
57203
57302
  name: "fmi_inspect_fmu",
57204
57303
  description: "Inspect a real FMI 2.0 .fmu archive, compute its SHA-256 digest, parse modelDescription.xml, and optionally verify variable/unit bindings against SysML v2 attributes.",
57205
57304
  inputSchema: INSPECT_FMU_INPUT_SCHEMA,
57305
+ ...viewerMeta,
57206
57306
  annotations: {
57207
57307
  readOnlyHint: true,
57208
57308
  destructiveHint: false,
@@ -57227,6 +57327,7 @@ function createMcpFmiServer(options = {}) {
57227
57327
  name: "fmi_simulate_fmu",
57228
57328
  description: "Execute a real native FMI 2.0 Co-Simulation .fmu archive with typed parameters, constant or scheduled inputs, and return verified time-series, flight track (for 6-DOF flight FMUs), and Compose Board physics metrics.",
57229
57329
  inputSchema: SIMULATE_FMU_INPUT_SCHEMA,
57330
+ ...viewerMeta,
57230
57331
  annotations: {
57231
57332
  readOnlyHint: true,
57232
57333
  destructiveHint: false,
@@ -57250,6 +57351,7 @@ function createMcpFmiServer(options = {}) {
57250
57351
  }
57251
57352
  );
57252
57353
  registerSnippetProvider(app, {
57354
+ ...hasDefaultWidget ? { runResourceUri: FMI_DEFAULT_WIDGET.uri } : {},
57253
57355
  runAnnotations: {
57254
57356
  readOnlyHint: true,
57255
57357
  destructiveHint: false,
@@ -57269,7 +57371,8 @@ function createMcpFmiServer(options = {}) {
57269
57371
  structuredContent: { value },
57270
57372
  _meta: {
57271
57373
  "io.casys/provenance": "verified-solver",
57272
- "io.casys/fmu-sha256": value.fmuSha256
57374
+ "io.casys/fmu-sha256": value.fmuSha256,
57375
+ ...viewsMeta
57273
57376
  }
57274
57377
  };
57275
57378
  } catch (error2) {
@@ -57292,7 +57395,8 @@ function createMcpFmiServer(options = {}) {
57292
57395
  structuredContent: { value },
57293
57396
  _meta: {
57294
57397
  "io.casys/provenance": "verified-solver",
57295
- "io.casys/fmu-sha256": value.fmuSha256
57398
+ "io.casys/fmu-sha256": value.fmuSha256,
57399
+ ...viewsMeta
57296
57400
  }
57297
57401
  };
57298
57402
  } catch (error2) {
@@ -57302,7 +57406,7 @@ function createMcpFmiServer(options = {}) {
57302
57406
  }
57303
57407
  ]
57304
57408
  });
57305
- return { app };
57409
+ return { app, registeredWidgets, hasDefaultWidget };
57306
57410
  }
57307
57411
 
57308
57412
  // server.ts
@@ -57392,6 +57496,7 @@ async function startMcpFmiCli(argv = process3.argv.slice(2)) {
57392
57496
  version: MCP_FMI_VERSION,
57393
57497
  tools: app.getToolNames(),
57394
57498
  snippets: ["inspect_fmu", "simulate_fmu"],
57499
+ widgets: FMI_WIDGETS.map((widget) => widget.uri),
57395
57500
  authEnabled: Boolean(bearerToken)
57396
57501
  });
57397
57502
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@casys/mcp-fmi",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Casys MCP server: mcp-fmi (MCP tools + @mcpview Code Mode snippets)",
5
5
  "type": "module",
6
6
  "bin": { "mcp-fmi": "mcp-fmi.mjs" },
7
- "files": ["mcp-fmi.mjs","LICENSE","README.md","runtime/run_fmi2.py"],
7
+ "files": ["mcp-fmi.mjs","LICENSE","README.md","runtime/run_fmi2.py","ui-dist/fmu-checks/index.html","ui-dist/fmu-time-series/index.html","ui-dist/fmu-variables/index.html","ui-dist/fmu-verdict/index.html","THIRD_PARTY_NOTICES.txt"],
8
8
  "engines": { "node": ">=20.0.0" },
9
9
  "license": "MIT",
10
10
  "repository": { "type": "git", "url": "git+https://github.com/superWorldSavior/mcp-fmi.git" },