@casys/mcp-openfoam 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/README.md +28 -0
- package/THIRD_PARTY_NOTICES.txt +1096 -0
- package/mcp-openfoam.mjs +106 -7
- package/package.json +2 -2
- package/ui-dist/axial-profile/index.html +3693 -0
- package/ui-dist/cfd-metrics/index.html +3693 -0
- package/ui-dist/cfd-verdict/index.html +3693 -0
package/mcp-openfoam.mjs
CHANGED
|
@@ -56058,7 +56058,7 @@ var McpApp = class {
|
|
|
56058
56058
|
continue;
|
|
56059
56059
|
}
|
|
56060
56060
|
const resourceUri = `ui://${config2.prefix}/${viewerName}`;
|
|
56061
|
-
const
|
|
56061
|
+
const readFile6 = config2.readFile;
|
|
56062
56062
|
const currentDistPath = distPath;
|
|
56063
56063
|
this.registerResource({
|
|
56064
56064
|
uri: resourceUri,
|
|
@@ -56066,7 +56066,7 @@ var McpApp = class {
|
|
|
56066
56066
|
description: `MCP App: ${viewerName}`,
|
|
56067
56067
|
mimeType: MCP_APP_MIME_TYPE
|
|
56068
56068
|
}, async () => {
|
|
56069
|
-
const html = await Promise.resolve(
|
|
56069
|
+
const html = await Promise.resolve(readFile6(currentDistPath));
|
|
56070
56070
|
const content = {
|
|
56071
56071
|
uri: resourceUri,
|
|
56072
56072
|
mimeType: MCP_APP_MIME_TYPE,
|
|
@@ -57858,8 +57858,93 @@ import { link, mkdir as mkdir5, open as open2, readdir as readdir3, readFile as
|
|
|
57858
57858
|
import { join as join3, resolve } from "node:path";
|
|
57859
57859
|
var encoder3 = new TextEncoder();
|
|
57860
57860
|
|
|
57861
|
+
// src/viewer.ts
|
|
57862
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
57863
|
+
import { statSync } from "node:fs";
|
|
57864
|
+
import { fileURLToPath } from "node:url";
|
|
57865
|
+
|
|
57866
|
+
// src/widgets.ts
|
|
57867
|
+
var CFD_VERDICT_WIDGET = {
|
|
57868
|
+
key: "cfd-verdict",
|
|
57869
|
+
uri: "ui://mcp-openfoam/cfd-verdict",
|
|
57870
|
+
kind: "stat",
|
|
57871
|
+
title: "CFD verdict",
|
|
57872
|
+
description: "Converged or not, mesh check, and the headline numbers of an OpenFOAM run.",
|
|
57873
|
+
supportedWidths: [280, 380, 520]
|
|
57874
|
+
};
|
|
57875
|
+
var CFD_METRICS_WIDGET = {
|
|
57876
|
+
key: "cfd-metrics",
|
|
57877
|
+
uri: "ui://mcp-openfoam/cfd-metrics",
|
|
57878
|
+
kind: "table",
|
|
57879
|
+
title: "CFD metrics",
|
|
57880
|
+
description: "Results, mesh quality and final residuals of an OpenFOAM run as one table.",
|
|
57881
|
+
supportedWidths: [340, 480, 680]
|
|
57882
|
+
};
|
|
57883
|
+
var AXIAL_PROFILE_WIDGET = {
|
|
57884
|
+
key: "axial-profile",
|
|
57885
|
+
uri: "ui://mcp-openfoam/axial-profile",
|
|
57886
|
+
kind: "chart",
|
|
57887
|
+
title: "Axial profile",
|
|
57888
|
+
description: "Velocity and pressure sampled along the nozzle axis.",
|
|
57889
|
+
supportedWidths: [320, 440, 640]
|
|
57890
|
+
};
|
|
57891
|
+
var OPENFOAM_WIDGETS = [
|
|
57892
|
+
CFD_VERDICT_WIDGET,
|
|
57893
|
+
CFD_METRICS_WIDGET,
|
|
57894
|
+
AXIAL_PROFILE_WIDGET
|
|
57895
|
+
];
|
|
57896
|
+
var OPENFOAM_DEFAULT_WIDGET = CFD_VERDICT_WIDGET;
|
|
57897
|
+
function openFoamWidgetByKey(key) {
|
|
57898
|
+
return OPENFOAM_WIDGETS.find((widget) => widget.key === key);
|
|
57899
|
+
}
|
|
57900
|
+
var DECLARED_VIEWS_META_KEY = "io.mcpview/views";
|
|
57901
|
+
function declaredViews(registered, nozzleResult) {
|
|
57902
|
+
return OPENFOAM_WIDGETS.filter((widget) => registered.includes(widget.key)).filter((widget) => nozzleResult || widget.key !== AXIAL_PROFILE_WIDGET.key).map((widget) => ({
|
|
57903
|
+
name: widget.key,
|
|
57904
|
+
resourceUri: widget.uri,
|
|
57905
|
+
title: widget.title,
|
|
57906
|
+
supportedWidths: widget.supportedWidths
|
|
57907
|
+
}));
|
|
57908
|
+
}
|
|
57909
|
+
|
|
57910
|
+
// src/viewer.ts
|
|
57911
|
+
var DENO_RELATIVE = `./ui/dist/${OPENFOAM_WIDGETS[0].key}/index.html`;
|
|
57912
|
+
function isRemote(path) {
|
|
57913
|
+
return path.startsWith("https://") || path.startsWith("http://");
|
|
57914
|
+
}
|
|
57915
|
+
function isFile(path) {
|
|
57916
|
+
try {
|
|
57917
|
+
return statSync(path).isFile();
|
|
57918
|
+
} catch {
|
|
57919
|
+
return false;
|
|
57920
|
+
}
|
|
57921
|
+
}
|
|
57922
|
+
function viewerModuleUrl(moduleUrl = import.meta.url) {
|
|
57923
|
+
const denoLayout = isRemote(moduleUrl) || isFile(fileURLToPath(new URL(DENO_RELATIVE, moduleUrl)));
|
|
57924
|
+
return denoLayout ? new URL("../server.ts", moduleUrl).href : moduleUrl;
|
|
57925
|
+
}
|
|
57926
|
+
function registerOpenFoamWidgets(app, moduleUrl = viewerModuleUrl()) {
|
|
57927
|
+
return app.registerViewers({
|
|
57928
|
+
prefix: "mcp-openfoam",
|
|
57929
|
+
viewers: OPENFOAM_WIDGETS.map((widget) => widget.key),
|
|
57930
|
+
moduleUrl,
|
|
57931
|
+
exists: (path) => isRemote(path) || isFile(path),
|
|
57932
|
+
readFile: async (path) => {
|
|
57933
|
+
if (!isRemote(path)) return await readFile5(path, "utf8");
|
|
57934
|
+
const response = await fetch(path);
|
|
57935
|
+
if (!response.ok) {
|
|
57936
|
+
throw new Error(
|
|
57937
|
+
`Unable to fetch OpenFOAM widget from ${path}: HTTP ${response.status}.`
|
|
57938
|
+
);
|
|
57939
|
+
}
|
|
57940
|
+
return await response.text();
|
|
57941
|
+
},
|
|
57942
|
+
humanName: (name) => `OpenFOAM ${openFoamWidgetByKey(name)?.title.toLowerCase() ?? name}`
|
|
57943
|
+
});
|
|
57944
|
+
}
|
|
57945
|
+
|
|
57861
57946
|
// src/server.ts
|
|
57862
|
-
var MCP_OPENFOAM_VERSION = "0.
|
|
57947
|
+
var MCP_OPENFOAM_VERSION = "0.2.0";
|
|
57863
57948
|
var NOZZLE_CFD_INPUT_SCHEMA = {
|
|
57864
57949
|
type: "object",
|
|
57865
57950
|
properties: {
|
|
@@ -58088,6 +58173,13 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58088
58173
|
"(or Level-2 snippets `solve_nozzle_cfd`, `solve_airfoil_cfd`, `run_case` via `list_snippets` / `run_snippet`)."
|
|
58089
58174
|
].join(" ")
|
|
58090
58175
|
});
|
|
58176
|
+
const registeredWidgets = registerOpenFoamWidgets(app, options.viewerModuleUrl).registered.filter((key) => OPENFOAM_WIDGETS.some((widget) => widget.key === key));
|
|
58177
|
+
const hasDefaultWidget = registeredWidgets.includes(OPENFOAM_DEFAULT_WIDGET.key);
|
|
58178
|
+
const nozzleViews = declaredViews(registeredWidgets, true);
|
|
58179
|
+
const nonNozzleViews = declaredViews(registeredWidgets, false);
|
|
58180
|
+
const nozzleViewsMeta = nozzleViews.length > 0 ? { [DECLARED_VIEWS_META_KEY]: nozzleViews } : {};
|
|
58181
|
+
const nonNozzleViewsMeta = nonNozzleViews.length > 0 ? { [DECLARED_VIEWS_META_KEY]: nonNozzleViews } : {};
|
|
58182
|
+
const viewerMeta = hasDefaultWidget ? { _meta: { ui: { resourceUri: OPENFOAM_DEFAULT_WIDGET.uri } } } : {};
|
|
58091
58183
|
app.registerTool(
|
|
58092
58184
|
{
|
|
58093
58185
|
name: "openfoam_solve_nozzle_cfd",
|
|
@@ -58098,7 +58190,8 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58098
58190
|
destructiveHint: false,
|
|
58099
58191
|
openWorldHint: false,
|
|
58100
58192
|
idempotentHint: true
|
|
58101
|
-
}
|
|
58193
|
+
},
|
|
58194
|
+
...viewerMeta
|
|
58102
58195
|
},
|
|
58103
58196
|
async (args, context2) => {
|
|
58104
58197
|
try {
|
|
@@ -58126,7 +58219,8 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58126
58219
|
destructiveHint: false,
|
|
58127
58220
|
openWorldHint: false,
|
|
58128
58221
|
idempotentHint: true
|
|
58129
|
-
}
|
|
58222
|
+
},
|
|
58223
|
+
...viewerMeta
|
|
58130
58224
|
},
|
|
58131
58225
|
async (args, context2) => {
|
|
58132
58226
|
try {
|
|
@@ -58154,7 +58248,8 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58154
58248
|
destructiveHint: false,
|
|
58155
58249
|
openWorldHint: false,
|
|
58156
58250
|
idempotentHint: true
|
|
58157
|
-
}
|
|
58251
|
+
},
|
|
58252
|
+
...viewerMeta
|
|
58158
58253
|
},
|
|
58159
58254
|
async (args, context2) => {
|
|
58160
58255
|
try {
|
|
@@ -58173,6 +58268,7 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58173
58268
|
}
|
|
58174
58269
|
);
|
|
58175
58270
|
registerSnippetProvider(app, {
|
|
58271
|
+
...hasDefaultWidget ? { runResourceUri: OPENFOAM_DEFAULT_WIDGET.uri } : {},
|
|
58176
58272
|
runAnnotations: {
|
|
58177
58273
|
readOnlyHint: true,
|
|
58178
58274
|
destructiveHint: false,
|
|
@@ -58195,6 +58291,7 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58195
58291
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
58196
58292
|
structuredContent: { value },
|
|
58197
58293
|
_meta: {
|
|
58294
|
+
...nozzleViewsMeta,
|
|
58198
58295
|
"io.casys/provenance": "verified-solver",
|
|
58199
58296
|
"io.casys/case-sha256": value.caseSha256
|
|
58200
58297
|
}
|
|
@@ -58219,6 +58316,7 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58219
58316
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
58220
58317
|
structuredContent: { value },
|
|
58221
58318
|
_meta: {
|
|
58319
|
+
...nonNozzleViewsMeta,
|
|
58222
58320
|
"io.casys/provenance": "verified-solver",
|
|
58223
58321
|
"io.casys/case-sha256": value.caseSha256
|
|
58224
58322
|
}
|
|
@@ -58243,6 +58341,7 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58243
58341
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
58244
58342
|
structuredContent: { value },
|
|
58245
58343
|
_meta: {
|
|
58344
|
+
...nonNozzleViewsMeta,
|
|
58246
58345
|
"io.casys/provenance": "verified-solver",
|
|
58247
58346
|
"io.casys/case-sha256": value.caseSha256
|
|
58248
58347
|
}
|
|
@@ -58255,7 +58354,7 @@ function createMcpOpenFoamServer(options = {}) {
|
|
|
58255
58354
|
]
|
|
58256
58355
|
});
|
|
58257
58356
|
void detectOpenFoamVersion(runnerOptionsFrom(options));
|
|
58258
|
-
return { app };
|
|
58357
|
+
return { app, registeredWidgets, hasDefaultWidget };
|
|
58259
58358
|
}
|
|
58260
58359
|
|
|
58261
58360
|
// server.ts
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casys/mcp-openfoam",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Casys MCP server: mcp-openfoam (MCP tools + @mcpview Code Mode snippets)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "mcp-openfoam": "mcp-openfoam.mjs" },
|
|
7
|
-
"files": ["mcp-openfoam.mjs","LICENSE","README.md"],
|
|
7
|
+
"files": ["mcp-openfoam.mjs","LICENSE","README.md","ui-dist/axial-profile/index.html","ui-dist/cfd-metrics/index.html","ui-dist/cfd-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-openfoam.git" },
|