@casys/mcp-prusaslicer 0.5.1 → 0.6.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 +26 -0
- package/THIRD_PARTY_NOTICES.md +773 -0
- package/mcp-prusaslicer.mjs +113 -8
- package/package.json +2 -2
- package/ui-dist/print-estimate/index.html +2435 -0
- package/ui-dist/slicing-profile/index.html +2435 -0
package/mcp-prusaslicer.mjs
CHANGED
|
@@ -39571,7 +39571,7 @@ var McpApp = class {
|
|
|
39571
39571
|
continue;
|
|
39572
39572
|
}
|
|
39573
39573
|
const resourceUri = `ui://${config2.prefix}/${viewerName}`;
|
|
39574
|
-
const
|
|
39574
|
+
const readFile6 = config2.readFile;
|
|
39575
39575
|
const currentDistPath = distPath;
|
|
39576
39576
|
this.registerResource({
|
|
39577
39577
|
uri: resourceUri,
|
|
@@ -39579,7 +39579,7 @@ var McpApp = class {
|
|
|
39579
39579
|
description: `MCP App: ${viewerName}`,
|
|
39580
39580
|
mimeType: MCP_APP_MIME_TYPE
|
|
39581
39581
|
}, async () => {
|
|
39582
|
-
const html = await Promise.resolve(
|
|
39582
|
+
const html = await Promise.resolve(readFile6(currentDistPath));
|
|
39583
39583
|
const content = {
|
|
39584
39584
|
uri: resourceUri,
|
|
39585
39585
|
mimeType: MCP_APP_MIME_TYPE,
|
|
@@ -56960,6 +56960,43 @@ function registerSnippetProvider(server, options) {
|
|
|
56960
56960
|
});
|
|
56961
56961
|
}
|
|
56962
56962
|
|
|
56963
|
+
// src/widgets.ts
|
|
56964
|
+
var PRINT_ESTIMATE_WIDGET = {
|
|
56965
|
+
key: "print-estimate",
|
|
56966
|
+
uri: "ui://mcp-prusaslicer/print-estimate",
|
|
56967
|
+
kind: "stat",
|
|
56968
|
+
title: "Print estimate",
|
|
56969
|
+
description: "Print time and filament consumption measured from the produced G-code.",
|
|
56970
|
+
supportedWidths: [280, 380, 520]
|
|
56971
|
+
};
|
|
56972
|
+
var SLICING_PROFILE_WIDGET = {
|
|
56973
|
+
key: "slicing-profile",
|
|
56974
|
+
uri: "ui://mcp-prusaslicer/slicing-profile",
|
|
56975
|
+
kind: "table",
|
|
56976
|
+
title: "Slicing profile",
|
|
56977
|
+
description: "Effective slicing parameters the estimate was produced with.",
|
|
56978
|
+
supportedWidths: [320, 440, 640]
|
|
56979
|
+
};
|
|
56980
|
+
var SLICER_WIDGETS = [
|
|
56981
|
+
PRINT_ESTIMATE_WIDGET,
|
|
56982
|
+
SLICING_PROFILE_WIDGET
|
|
56983
|
+
];
|
|
56984
|
+
var SLICER_DEFAULT_WIDGET = PRINT_ESTIMATE_WIDGET;
|
|
56985
|
+
function slicerWidgetByKey(key) {
|
|
56986
|
+
return SLICER_WIDGETS.find((widget) => widget.key === key);
|
|
56987
|
+
}
|
|
56988
|
+
var DECLARED_VIEWS_META_KEY = "io.mcpview/views";
|
|
56989
|
+
function declaredViews(registeredKeys) {
|
|
56990
|
+
return SLICER_WIDGETS.filter(
|
|
56991
|
+
(widget) => registeredKeys === void 0 || registeredKeys.includes(widget.key)
|
|
56992
|
+
).map((widget) => ({
|
|
56993
|
+
name: widget.key,
|
|
56994
|
+
resourceUri: widget.uri,
|
|
56995
|
+
title: widget.title.slice(0, 120),
|
|
56996
|
+
supportedWidths: [...widget.supportedWidths]
|
|
56997
|
+
}));
|
|
56998
|
+
}
|
|
56999
|
+
|
|
56963
57000
|
// src/snippets.ts
|
|
56964
57001
|
var TOOL_PREFIX = "prusaslicer_";
|
|
56965
57002
|
function snippetNameFor(toolName) {
|
|
@@ -56972,8 +57009,15 @@ function failure3(code, message2) {
|
|
|
56972
57009
|
structuredContent: { error: { code, message: message2 } }
|
|
56973
57010
|
};
|
|
56974
57011
|
}
|
|
56975
|
-
function
|
|
57012
|
+
function snippetValue(result) {
|
|
57013
|
+
if (result !== null && typeof result === "object" && "structuredContent" in result) {
|
|
57014
|
+
return result.structuredContent;
|
|
57015
|
+
}
|
|
57016
|
+
return result;
|
|
57017
|
+
}
|
|
57018
|
+
function registerSlicerSnippets(app, tools, runResourceUri, views = declaredViews()) {
|
|
56976
57019
|
registerSnippetProvider(app, {
|
|
57020
|
+
...runResourceUri ? { runResourceUri } : {},
|
|
56977
57021
|
runAnnotations: {
|
|
56978
57022
|
readOnlyHint: true,
|
|
56979
57023
|
destructiveHint: false,
|
|
@@ -56986,11 +57030,13 @@ function registerSlicerSnippets(app, tools) {
|
|
|
56986
57030
|
inputSchema: tool.inputSchema,
|
|
56987
57031
|
async run(input) {
|
|
56988
57032
|
try {
|
|
56989
|
-
const value = await tool.handler(input);
|
|
57033
|
+
const value = snippetValue(await tool.handler(input));
|
|
56990
57034
|
return {
|
|
56991
57035
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
56992
57036
|
structuredContent: { value },
|
|
56993
57037
|
_meta: {
|
|
57038
|
+
...views.length > 0 ? { [DECLARED_VIEWS_META_KEY]: views } : {},
|
|
57039
|
+
...runResourceUri ? { ui: { resourceUri: runResourceUri } } : {},
|
|
56994
57040
|
"io.casys/provenance": "verified-solver",
|
|
56995
57041
|
"io.casys/engine": "mcp-prusaslicer/prusa-slicer"
|
|
56996
57042
|
}
|
|
@@ -57005,13 +57051,54 @@ function registerSlicerSnippets(app, tools) {
|
|
|
57005
57051
|
});
|
|
57006
57052
|
}
|
|
57007
57053
|
|
|
57054
|
+
// src/viewer.ts
|
|
57055
|
+
import { readFile as readFile5 } from "node:fs/promises";
|
|
57056
|
+
import { statSync } from "node:fs";
|
|
57057
|
+
function isRemote(path) {
|
|
57058
|
+
return path.startsWith("https://") || path.startsWith("http://");
|
|
57059
|
+
}
|
|
57060
|
+
var defaultViewerFileSystem = {
|
|
57061
|
+
exists(path) {
|
|
57062
|
+
if (isRemote(path)) return true;
|
|
57063
|
+
try {
|
|
57064
|
+
return statSync(path).isFile();
|
|
57065
|
+
} catch (error2) {
|
|
57066
|
+
if (isNotFound(error2)) return false;
|
|
57067
|
+
const { code, name } = error2 ?? {};
|
|
57068
|
+
if (code === "EACCES" || code === "EPERM" || name === "PermissionDenied" || name === "NotCapable") return false;
|
|
57069
|
+
throw error2;
|
|
57070
|
+
}
|
|
57071
|
+
},
|
|
57072
|
+
async readFile(path) {
|
|
57073
|
+
if (!isRemote(path)) return await readFile5(path, "utf8");
|
|
57074
|
+
const response = await fetch(path);
|
|
57075
|
+
if (!response.ok) {
|
|
57076
|
+
throw new Error(
|
|
57077
|
+
`Unable to fetch the PrusaSlicer widget from ${path}: HTTP ${response.status}.`
|
|
57078
|
+
);
|
|
57079
|
+
}
|
|
57080
|
+
return await response.text();
|
|
57081
|
+
}
|
|
57082
|
+
};
|
|
57083
|
+
function registerSlicerWidgets(app, moduleUrl, fileSystem = defaultViewerFileSystem) {
|
|
57084
|
+
return app.registerViewers({
|
|
57085
|
+
prefix: "mcp-prusaslicer",
|
|
57086
|
+
viewers: SLICER_WIDGETS.map((widget) => widget.key),
|
|
57087
|
+
moduleUrl,
|
|
57088
|
+
exists: fileSystem.exists,
|
|
57089
|
+
readFile: fileSystem.readFile,
|
|
57090
|
+
humanName: (name) => `PrusaSlicer ${slicerWidgetByKey(name)?.title.toLowerCase() ?? name}`
|
|
57091
|
+
});
|
|
57092
|
+
}
|
|
57093
|
+
|
|
57008
57094
|
// server.ts
|
|
57009
|
-
var VERSION2 = "0.
|
|
57095
|
+
var VERSION2 = "0.6.0";
|
|
57010
57096
|
var DEFAULT_PORT = 3022;
|
|
57011
57097
|
var DEFAULT_HOSTNAME = "127.0.0.1";
|
|
57012
57098
|
function createSlicerServer(options = {}) {
|
|
57013
57099
|
const client = new SlicerToolsClient();
|
|
57014
57100
|
const handlers = client.buildHandlersMap();
|
|
57101
|
+
const tools = client.toMCPFormat();
|
|
57015
57102
|
const app = new McpApp({
|
|
57016
57103
|
name: "mcp-prusaslicer",
|
|
57017
57104
|
version: VERSION2,
|
|
@@ -57022,9 +57109,27 @@ function createSlicerServer(options = {}) {
|
|
|
57022
57109
|
instructions: "FDM slicing estimation via PrusaSlicer. Supply an admitted .stl path and a PrusaSlicer INI profile; receive print-time and material-consumption measurements from the real G-code. No prices \u2014 pricing is downstream (erpnext).",
|
|
57023
57110
|
logger: options.logger ?? ((message2) => console.error(`[mcp-prusaslicer] ${message2}`))
|
|
57024
57111
|
});
|
|
57025
|
-
app.
|
|
57026
|
-
|
|
57027
|
-
|
|
57112
|
+
const registeredWidgets = registerSlicerWidgets(app, import.meta.url).registered.filter((key) => SLICER_WIDGETS.some((widget) => widget.key === key));
|
|
57113
|
+
const hasDefaultWidget = registeredWidgets.includes(SLICER_DEFAULT_WIDGET.key);
|
|
57114
|
+
if (hasDefaultWidget) {
|
|
57115
|
+
for (const tool of tools) {
|
|
57116
|
+
tool._meta = {
|
|
57117
|
+
ui: { resourceUri: SLICER_DEFAULT_WIDGET.uri }
|
|
57118
|
+
};
|
|
57119
|
+
}
|
|
57120
|
+
} else {
|
|
57121
|
+
console.error(
|
|
57122
|
+
"[mcp-prusaslicer] Widgets are not built; run `deno task build:ui`."
|
|
57123
|
+
);
|
|
57124
|
+
}
|
|
57125
|
+
app.registerTools(tools, handlers);
|
|
57126
|
+
registerSlicerSnippets(
|
|
57127
|
+
app,
|
|
57128
|
+
allTools,
|
|
57129
|
+
hasDefaultWidget ? SLICER_DEFAULT_WIDGET.uri : void 0,
|
|
57130
|
+
declaredViews(registeredWidgets)
|
|
57131
|
+
);
|
|
57132
|
+
return { app, registeredWidgets, hasDefaultWidget };
|
|
57028
57133
|
}
|
|
57029
57134
|
function parsePort(value, flag) {
|
|
57030
57135
|
if (value === void 0 || !/^[0-9]+$/.test(value)) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casys/mcp-prusaslicer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Casys MCP server: mcp-prusaslicer (MCP tools + @mcpview Code Mode snippets)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "mcp-prusaslicer": "mcp-prusaslicer.mjs" },
|
|
7
|
-
"files": ["mcp-prusaslicer.mjs","LICENSE","README.md"],
|
|
7
|
+
"files": ["mcp-prusaslicer.mjs","LICENSE","README.md","ui-dist/print-estimate/index.html","ui-dist/slicing-profile/index.html","THIRD_PARTY_NOTICES.md"],
|
|
8
8
|
"engines": { "node": ">=20.0.0" },
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": { "type": "git", "url": "git+https://github.com/superWorldSavior/mcp-prusaslicer.git" },
|