sceneview-mcp 4.4.0 → 4.5.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 +38 -8
- package/dist/generate-model-output.js +241 -0
- package/dist/generate-model-parametric.js +449 -0
- package/dist/generate-model-tool.js +153 -0
- package/dist/generate-model.js +5 -0
- package/dist/generated/llms-txt.js +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/glb.js +227 -0
- package/dist/server.js +5 -1
- package/dist/tools/definitions.js +79 -8
- package/dist/tools/handler.js +7 -15
- package/package.json +5 -4
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// build time so the MCP server, telemetry, and the install-snippet
|
|
5
5
|
// generators all report the actually-published versions instead of
|
|
6
6
|
// stale hardcoded constants. See #941.
|
|
7
|
-
export const PACKAGE_VERSION = "4.
|
|
7
|
+
export const PACKAGE_VERSION = "4.5.0";
|
|
8
8
|
export const LATEST_SCENEVIEW_RELEASE = "4.76.0";
|
|
9
9
|
// The pub.dev coordinate for `flutter_sceneview`, read from the plugin's
|
|
10
10
|
// README. Deliberately NOT LATEST_SCENEVIEW_RELEASE: pub.dev lags the SDK,
|
package/dist/glb.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free GLB (binary glTF 2.0) helpers used by
|
|
3
|
+
* `generate_3d_model`: write a GLB from a JSON document + binary buffer,
|
|
4
|
+
* parse one back, measure its world-space bounding box, and rescale it
|
|
5
|
+
* uniformly without touching the vertex data.
|
|
6
|
+
*
|
|
7
|
+
* Measurement reads only the `POSITION` accessor `min`/`max` that the glTF
|
|
8
|
+
* spec makes mandatory, transformed by each node's TRS/matrix. It never
|
|
9
|
+
* decodes vertex buffers, so it also works on quantized or Draco-compressed
|
|
10
|
+
* meshes. Skins and morph targets are not evaluated (bind pose only).
|
|
11
|
+
*
|
|
12
|
+
* glTF's unit is the metre (spec §3.4), so every size reported here is in
|
|
13
|
+
* metres.
|
|
14
|
+
*/
|
|
15
|
+
const GLB_MAGIC = 0x46546c67; // "glTF"
|
|
16
|
+
const CHUNK_JSON = 0x4e4f534a; // "JSON"
|
|
17
|
+
const CHUNK_BIN = 0x004e4942; // "BIN\0"
|
|
18
|
+
export class GlbError extends Error {
|
|
19
|
+
}
|
|
20
|
+
function pad4(length) {
|
|
21
|
+
return (4 - (length % 4)) % 4;
|
|
22
|
+
}
|
|
23
|
+
/** Serialize a glTF JSON document and an optional binary buffer as a GLB. */
|
|
24
|
+
export function writeGlb(json, bin) {
|
|
25
|
+
const jsonBytes = new TextEncoder().encode(JSON.stringify(json));
|
|
26
|
+
const jsonPad = pad4(jsonBytes.length);
|
|
27
|
+
const binPad = bin ? pad4(bin.length) : 0;
|
|
28
|
+
const jsonChunk = 8 + jsonBytes.length + jsonPad;
|
|
29
|
+
const binChunk = bin ? 8 + bin.length + binPad : 0;
|
|
30
|
+
const total = 12 + jsonChunk + binChunk;
|
|
31
|
+
const out = new Uint8Array(total);
|
|
32
|
+
const view = new DataView(out.buffer);
|
|
33
|
+
view.setUint32(0, GLB_MAGIC, true);
|
|
34
|
+
view.setUint32(4, 2, true);
|
|
35
|
+
view.setUint32(8, total, true);
|
|
36
|
+
view.setUint32(12, jsonBytes.length + jsonPad, true);
|
|
37
|
+
view.setUint32(16, CHUNK_JSON, true);
|
|
38
|
+
out.set(jsonBytes, 20);
|
|
39
|
+
out.fill(0x20, 20 + jsonBytes.length, 20 + jsonBytes.length + jsonPad); // spaces
|
|
40
|
+
if (bin) {
|
|
41
|
+
const at = 12 + jsonChunk;
|
|
42
|
+
view.setUint32(at, bin.length + binPad, true);
|
|
43
|
+
view.setUint32(at + 4, CHUNK_BIN, true);
|
|
44
|
+
out.set(bin, at + 8); // padding bytes are already zero
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Parse a GLB container. Throws `GlbError` on anything that is not GLB 2.0. */
|
|
49
|
+
export function parseGlb(bytes) {
|
|
50
|
+
if (bytes.length < 20)
|
|
51
|
+
throw new GlbError("File is too small to be a GLB.");
|
|
52
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
53
|
+
if (view.getUint32(0, true) !== GLB_MAGIC)
|
|
54
|
+
throw new GlbError("Not a GLB file (bad magic).");
|
|
55
|
+
if (view.getUint32(4, true) !== 2)
|
|
56
|
+
throw new GlbError("Only glTF 2.0 GLB files are supported.");
|
|
57
|
+
const declared = view.getUint32(8, true);
|
|
58
|
+
if (declared > bytes.length)
|
|
59
|
+
throw new GlbError("GLB header length exceeds the file size.");
|
|
60
|
+
let json = null;
|
|
61
|
+
let bin = null;
|
|
62
|
+
let offset = 12;
|
|
63
|
+
while (offset + 8 <= declared) {
|
|
64
|
+
const length = view.getUint32(offset, true);
|
|
65
|
+
const type = view.getUint32(offset + 4, true);
|
|
66
|
+
const start = offset + 8;
|
|
67
|
+
if (start + length > declared)
|
|
68
|
+
throw new GlbError("GLB chunk overruns the file.");
|
|
69
|
+
const chunk = bytes.subarray(start, start + length);
|
|
70
|
+
if (type === CHUNK_JSON && json === null) {
|
|
71
|
+
try {
|
|
72
|
+
json = JSON.parse(new TextDecoder("utf-8").decode(chunk));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
throw new GlbError("GLB JSON chunk is not valid JSON.");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (type === CHUNK_BIN && bin === null) {
|
|
79
|
+
bin = chunk;
|
|
80
|
+
}
|
|
81
|
+
offset = start + length;
|
|
82
|
+
}
|
|
83
|
+
if (!json || typeof json !== "object" || !json.asset) {
|
|
84
|
+
throw new GlbError("GLB has no glTF JSON chunk.");
|
|
85
|
+
}
|
|
86
|
+
return { json, bin };
|
|
87
|
+
}
|
|
88
|
+
const IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
89
|
+
function multiply(a, b) {
|
|
90
|
+
const out = new Array(16).fill(0);
|
|
91
|
+
for (let col = 0; col < 4; col++) {
|
|
92
|
+
for (let row = 0; row < 4; row++) {
|
|
93
|
+
let sum = 0;
|
|
94
|
+
for (let k = 0; k < 4; k++)
|
|
95
|
+
sum += a[k * 4 + row] * b[col * 4 + k];
|
|
96
|
+
out[col * 4 + row] = sum;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
function localMatrix(node) {
|
|
102
|
+
if (Array.isArray(node.matrix) && node.matrix.length === 16)
|
|
103
|
+
return node.matrix;
|
|
104
|
+
const [tx, ty, tz] = node.translation ?? [0, 0, 0];
|
|
105
|
+
const [qx, qy, qz, qw] = node.rotation ?? [0, 0, 0, 1];
|
|
106
|
+
const [sx, sy, sz] = node.scale ?? [1, 1, 1];
|
|
107
|
+
const xx = qx * qx;
|
|
108
|
+
const yy = qy * qy;
|
|
109
|
+
const zz = qz * qz;
|
|
110
|
+
const xy = qx * qy;
|
|
111
|
+
const xz = qx * qz;
|
|
112
|
+
const yz = qy * qz;
|
|
113
|
+
const wx = qw * qx;
|
|
114
|
+
const wy = qw * qy;
|
|
115
|
+
const wz = qw * qz;
|
|
116
|
+
return [
|
|
117
|
+
(1 - 2 * (yy + zz)) * sx,
|
|
118
|
+
2 * (xy + wz) * sx,
|
|
119
|
+
2 * (xz - wy) * sx,
|
|
120
|
+
0,
|
|
121
|
+
2 * (xy - wz) * sy,
|
|
122
|
+
(1 - 2 * (xx + zz)) * sy,
|
|
123
|
+
2 * (yz + wx) * sy,
|
|
124
|
+
0,
|
|
125
|
+
2 * (xz + wy) * sz,
|
|
126
|
+
2 * (yz - wx) * sz,
|
|
127
|
+
(1 - 2 * (xx + yy)) * sz,
|
|
128
|
+
0,
|
|
129
|
+
tx,
|
|
130
|
+
ty,
|
|
131
|
+
tz,
|
|
132
|
+
1,
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
function transformPoint(m, p) {
|
|
136
|
+
return [
|
|
137
|
+
m[0] * p[0] + m[4] * p[1] + m[8] * p[2] + m[12],
|
|
138
|
+
m[1] * p[0] + m[5] * p[1] + m[9] * p[2] + m[13],
|
|
139
|
+
m[2] * p[0] + m[6] * p[1] + m[10] * p[2] + m[14],
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
/** Root node indices of the default scene (or every node that is no one's child). */
|
|
143
|
+
function sceneRoots(json) {
|
|
144
|
+
const scenes = json.scenes ?? [];
|
|
145
|
+
const sceneIndex = typeof json.scene === "number" ? json.scene : 0;
|
|
146
|
+
const scene = scenes[sceneIndex];
|
|
147
|
+
if (scene?.nodes)
|
|
148
|
+
return scene.nodes;
|
|
149
|
+
const nodes = json.nodes ?? [];
|
|
150
|
+
const children = new Set(nodes.flatMap((n) => n.children ?? []));
|
|
151
|
+
return nodes.map((_, i) => i).filter((i) => !children.has(i));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* World-space axis-aligned bounding box of the default scene, in metres.
|
|
155
|
+
* Returns `null` when no mesh primitive carries `POSITION` min/max.
|
|
156
|
+
*/
|
|
157
|
+
export function measureGlb(json) {
|
|
158
|
+
const nodes = json.nodes ?? [];
|
|
159
|
+
const meshes = json.meshes ?? [];
|
|
160
|
+
const accessors = json.accessors ?? [];
|
|
161
|
+
const min = [Infinity, Infinity, Infinity];
|
|
162
|
+
const max = [-Infinity, -Infinity, -Infinity];
|
|
163
|
+
let found = false;
|
|
164
|
+
const visiting = new Set();
|
|
165
|
+
const visit = (index, parent) => {
|
|
166
|
+
const node = nodes[index];
|
|
167
|
+
if (!node || visiting.has(index))
|
|
168
|
+
return; // malformed cycle guard
|
|
169
|
+
visiting.add(index);
|
|
170
|
+
const world = multiply(parent, localMatrix(node));
|
|
171
|
+
const mesh = typeof node.mesh === "number" ? meshes[node.mesh] : undefined;
|
|
172
|
+
for (const primitive of mesh?.primitives ?? []) {
|
|
173
|
+
const accessor = accessors[primitive.attributes?.POSITION];
|
|
174
|
+
const lo = accessor?.min;
|
|
175
|
+
const hi = accessor?.max;
|
|
176
|
+
if (!Array.isArray(lo) || !Array.isArray(hi) || lo.length < 3 || hi.length < 3)
|
|
177
|
+
continue;
|
|
178
|
+
for (let corner = 0; corner < 8; corner++) {
|
|
179
|
+
const p = transformPoint(world, [
|
|
180
|
+
corner & 1 ? hi[0] : lo[0],
|
|
181
|
+
corner & 2 ? hi[1] : lo[1],
|
|
182
|
+
corner & 4 ? hi[2] : lo[2],
|
|
183
|
+
]);
|
|
184
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
185
|
+
if (p[axis] < min[axis])
|
|
186
|
+
min[axis] = p[axis];
|
|
187
|
+
if (p[axis] > max[axis])
|
|
188
|
+
max[axis] = p[axis];
|
|
189
|
+
}
|
|
190
|
+
found = true;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
for (const child of node.children ?? [])
|
|
194
|
+
visit(child, world);
|
|
195
|
+
visiting.delete(index);
|
|
196
|
+
};
|
|
197
|
+
for (const root of sceneRoots(json))
|
|
198
|
+
visit(root, IDENTITY);
|
|
199
|
+
return found ? { min, max } : null;
|
|
200
|
+
}
|
|
201
|
+
export function dimensionsOf(bounds) {
|
|
202
|
+
return {
|
|
203
|
+
width: bounds.max[0] - bounds.min[0],
|
|
204
|
+
height: bounds.max[1] - bounds.min[1],
|
|
205
|
+
depth: bounds.max[2] - bounds.min[2],
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Uniformly rescale the default scene by `factor`, by parenting its root
|
|
210
|
+
* nodes under one new node carrying `scale: [f, f, f]`. Vertex data is left
|
|
211
|
+
* untouched, so this is safe for compressed or quantized meshes.
|
|
212
|
+
* Returns a new document; the input is not mutated.
|
|
213
|
+
*/
|
|
214
|
+
export function scaleGlbDocument(json, factor) {
|
|
215
|
+
const copy = structuredClone(json);
|
|
216
|
+
const nodes = copy.nodes ?? [];
|
|
217
|
+
const roots = sceneRoots(copy);
|
|
218
|
+
const wrapperIndex = nodes.length;
|
|
219
|
+
nodes.push({ name: "sceneview_scale_root", scale: [factor, factor, factor], children: roots });
|
|
220
|
+
copy.nodes = nodes;
|
|
221
|
+
const scenes = copy.scenes && copy.scenes.length > 0 ? copy.scenes : [{}];
|
|
222
|
+
const sceneIndex = typeof copy.scene === "number" ? copy.scene : 0;
|
|
223
|
+
scenes[sceneIndex] = { ...scenes[sceneIndex], nodes: [wrapperIndex] };
|
|
224
|
+
copy.scenes = scenes;
|
|
225
|
+
copy.scene = sceneIndex;
|
|
226
|
+
return copy;
|
|
227
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -190,7 +190,11 @@ export function createSceneViewServer(options = {}) {
|
|
|
190
190
|
// The dispatcher returns the narrower SceneView `ToolResult` shape, which
|
|
191
191
|
// structurally matches the MCP SDK's `CallToolResult` but TS can't prove
|
|
192
192
|
// it (the SDK's zod-derived type has additional optional members).
|
|
193
|
-
|
|
193
|
+
// `surface` lets a tool refuse what only makes sense on the user's own
|
|
194
|
+
// machine (`generate_3d_model`'s `save_to_path` writes to local disk).
|
|
195
|
+
const result = await dispatchTool(toolName, args, {
|
|
196
|
+
extras: { surface: remote ? "remote" : "stdio" },
|
|
197
|
+
});
|
|
194
198
|
return negotiateResult(result);
|
|
195
199
|
});
|
|
196
200
|
return server;
|
|
@@ -680,27 +680,97 @@ export const TOOL_DEFINITIONS = [
|
|
|
680
680
|
},
|
|
681
681
|
{
|
|
682
682
|
name: "generate_3d_model",
|
|
683
|
-
description: 'Generates a brand-new 3D model (GLB)
|
|
683
|
+
description: 'Generates a brand-new 3D model (GLB) at real-world scale — use this when `search_models` finds no suitable existing asset. Three modes, all free on SceneView\'s side (there is no paid tier and no SceneView-hosted generation API): (1) provider "parametric" — deterministic primitives (box, cylinder, cone, sphere, torus) from a structured `parts` list, built locally with NO API key and no network; pick it for furniture blockouts, props and placeholders whose dimensions are known ("a 1.2 × 0.75 × 0.6 m desk"). Passing `parts` without `provider` selects it. (2) "trellis" — Microsoft TRELLIS.2 on Runware, BYOK `RUNWARE_API_KEY` (my.runware.ai/keys), roughly $0.01-0.03 per model as of November 2026, ~40-90 s, text→3D renders a FLUX concept image first. (3) "tripo" — Tripo AI, BYOK `TRIPO_API_KEY` (platform.tripo3d.ai/api-keys), roughly $0.10-0.25 per fast and ~$0.41 per hd generation as of July 2026. Provider generations are billed to the USER\'S own account. Without `provider` or `parts`, Tripo is used when `TRIPO_API_KEY` is set, otherwise TRELLIS.2 when `RUNWARE_API_KEY` is set; with no key the tool returns setup instructions. Output is in metres (glTF\'s unit): the result reports the model\'s size, and `targetSize` (e.g. { heightMeters: 0.75 }) rescales it uniformly so that dimension matches. `save_to_path` writes the GLB to an absolute local `.glb` path (local package only; the parent directory must exist; an existing file is never replaced unless `overwrite: true`). Without `save_to_path`, provider mode returns a temporary GLB download URL (expires ~5 minutes) and parametric mode returns the GLB base64 in `structuredContent.glbBase64`. Load the result with `rememberModelInstance(modelLoader, ...)`.',
|
|
684
684
|
inputSchema: {
|
|
685
685
|
type: "object",
|
|
686
686
|
properties: {
|
|
687
|
+
provider: {
|
|
688
|
+
type: "string",
|
|
689
|
+
enum: ["parametric", "trellis", "tripo"],
|
|
690
|
+
description: '"parametric": deterministic primitives from `parts`, no key, no network. "trellis": Microsoft TRELLIS.2 on Runware (`RUNWARE_API_KEY`, a few US cents per model, image-faithful PBR mesh). "tripo": Tripo AI (`TRIPO_API_KEY`). Omit to use "parametric" when `parts` is given, otherwise whichever key is configured (Tripo first).',
|
|
691
|
+
},
|
|
687
692
|
prompt: {
|
|
688
693
|
type: "string",
|
|
689
|
-
description: '
|
|
694
|
+
description: 'Provider modes: text description of the model to generate (text→3D), e.g. "a low-poly cactus in a striped pot". Max 1024 characters. Provide exactly one of `prompt` or `imageUrl`.',
|
|
690
695
|
},
|
|
691
696
|
imageUrl: {
|
|
692
697
|
type: "string",
|
|
693
|
-
description: "
|
|
698
|
+
description: "Provider modes: public HTTPS URL of a source image to convert to 3D (image→3D). JPEG or PNG, max 20 MB. Provide exactly one of `prompt` or `imageUrl`.",
|
|
694
699
|
},
|
|
695
700
|
quality: {
|
|
696
701
|
type: "string",
|
|
697
702
|
enum: ["fast", "hd"],
|
|
698
|
-
description: '"fast" (default): Tripo P1 low-poly (~25-30 s) or TRELLIS.2 1024³ — cheap, AR-ready. "hd": Tripo H3.1 quad topology (up to ~100 s) or TRELLIS.2 1536³ — more detail, higher cost.',
|
|
703
|
+
description: 'Provider modes. "fast" (default): Tripo P1 low-poly (~25-30 s) or TRELLIS.2 1024³ — cheap, AR-ready. "hd": Tripo H3.1 quad topology (up to ~100 s) or TRELLIS.2 1536³ — more detail, higher cost.',
|
|
699
704
|
},
|
|
700
|
-
|
|
705
|
+
parts: {
|
|
706
|
+
type: "array",
|
|
707
|
+
maxItems: 64,
|
|
708
|
+
description: "Parametric mode: the primitives the model is assembled from (union by composition, one node per part; no boolean subtraction). Sizes and positions are in `units`; y is up; `position` is the centre of the part.",
|
|
709
|
+
items: {
|
|
710
|
+
type: "object",
|
|
711
|
+
properties: {
|
|
712
|
+
shape: { type: "string", enum: ["box", "cylinder", "cone", "sphere", "torus"] },
|
|
713
|
+
name: { type: "string" },
|
|
714
|
+
size: {
|
|
715
|
+
type: "array",
|
|
716
|
+
items: { type: "number" },
|
|
717
|
+
minItems: 3,
|
|
718
|
+
maxItems: 3,
|
|
719
|
+
description: "box: [width (x), height (y), depth (z)].",
|
|
720
|
+
},
|
|
721
|
+
radius: {
|
|
722
|
+
type: "number",
|
|
723
|
+
description: "cylinder / cone / sphere: radius. torus: ring radius (centre of the tube).",
|
|
724
|
+
},
|
|
725
|
+
radiusTop: {
|
|
726
|
+
type: "number",
|
|
727
|
+
description: "cylinder: top radius (defaults to `radius`; 0 = cone).",
|
|
728
|
+
},
|
|
729
|
+
height: { type: "number", description: "cylinder / cone: height along y." },
|
|
730
|
+
tube: { type: "number", description: "torus: tube radius." },
|
|
731
|
+
position: {
|
|
732
|
+
type: "array",
|
|
733
|
+
items: { type: "number" },
|
|
734
|
+
minItems: 3,
|
|
735
|
+
maxItems: 3,
|
|
736
|
+
description: "[x, y, z] centre of the part.",
|
|
737
|
+
},
|
|
738
|
+
rotation: {
|
|
739
|
+
type: "array",
|
|
740
|
+
items: { type: "number" },
|
|
741
|
+
minItems: 3,
|
|
742
|
+
maxItems: 3,
|
|
743
|
+
description: "Euler degrees [x, y, z], applied X then Y then Z.",
|
|
744
|
+
},
|
|
745
|
+
color: { type: "string", description: '"#rrggbb" base colour.' },
|
|
746
|
+
metallic: { type: "number", minimum: 0, maximum: 1 },
|
|
747
|
+
roughness: { type: "number", minimum: 0, maximum: 1 },
|
|
748
|
+
},
|
|
749
|
+
required: ["shape"],
|
|
750
|
+
},
|
|
751
|
+
},
|
|
752
|
+
units: {
|
|
701
753
|
type: "string",
|
|
702
|
-
enum: ["
|
|
703
|
-
description: '
|
|
754
|
+
enum: ["m", "cm", "mm", "in", "ft"],
|
|
755
|
+
description: 'Parametric mode: unit of every size and position in `parts` (default "m"). The GLB is always written in metres.',
|
|
756
|
+
},
|
|
757
|
+
targetSize: {
|
|
758
|
+
type: "object",
|
|
759
|
+
description: "Optional real-world size: set exactly one key and the model is scaled uniformly so that dimension matches, in metres. Example: { heightMeters: 0.75 }.",
|
|
760
|
+
properties: {
|
|
761
|
+
heightMeters: { type: "number" },
|
|
762
|
+
widthMeters: { type: "number" },
|
|
763
|
+
depthMeters: { type: "number" },
|
|
764
|
+
maxDimensionMeters: { type: "number" },
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
save_to_path: {
|
|
768
|
+
type: "string",
|
|
769
|
+
description: "Optional absolute path of a `.glb` file to write the model to (local package only). The parent directory must already exist. Validated before any generation runs.",
|
|
770
|
+
},
|
|
771
|
+
overwrite: {
|
|
772
|
+
type: "boolean",
|
|
773
|
+
description: "Allow `save_to_path` to replace an existing regular file. Default false: an existing file is never touched.",
|
|
704
774
|
},
|
|
705
775
|
},
|
|
706
776
|
required: [],
|
|
@@ -708,7 +778,8 @@ export const TOOL_DEFINITIONS = [
|
|
|
708
778
|
annotations: {
|
|
709
779
|
readOnlyHint: false,
|
|
710
780
|
openWorldHint: true,
|
|
711
|
-
|
|
781
|
+
// `save_to_path` + `overwrite: true` can replace a local file.
|
|
782
|
+
destructiveHint: true,
|
|
712
783
|
title: "Generate a 3D model",
|
|
713
784
|
},
|
|
714
785
|
},
|
package/dist/tools/handler.js
CHANGED
|
@@ -23,7 +23,7 @@ import { fetchAndroidDoc, formatAndroidDocsFetch, formatAndroidDocsSearch, searc
|
|
|
23
23
|
import { formatArtifactResponse, generateArtifact, validateArtifactInput, } from "../artifact.js";
|
|
24
24
|
import { autoDetectIssue, DEBUG_CATEGORIES, getDebugGuide, } from "../debug-issue.js";
|
|
25
25
|
import { COLLISION_GUIDE, MATERIAL_GUIDE, MODEL_OPTIMIZATION_GUIDE, WEB_RENDERING_GUIDE, } from "../extra-guides.js";
|
|
26
|
-
import {
|
|
26
|
+
import { runGenerate3dModel } from "../generate-model-tool.js";
|
|
27
27
|
import { formatGeneratedScene, generateScene } from "../generate-scene.js";
|
|
28
28
|
import { LLMS_TXT } from "../generated/llms-txt.js";
|
|
29
29
|
import { IOS_NODE_TYPE_COUNT, LATEST_SCENEVIEW_RELEASE } from "../generated/version.js";
|
|
@@ -63,10 +63,11 @@ const NODE_SECTIONS = parseNodeSections(API_DOCS);
|
|
|
63
63
|
* @param toolName MCP tool name, e.g. `"get_sample"`.
|
|
64
64
|
* @param args Arguments bag from the MCP client. `undefined` and
|
|
65
65
|
* `null` are both tolerated.
|
|
66
|
-
* @param
|
|
67
|
-
*
|
|
66
|
+
* @param ctx Optional context (user, request id, `extras.surface`).
|
|
67
|
+
* `generate_3d_model` reads it to refuse `save_to_path`
|
|
68
|
+
* on the shared remote surface.
|
|
68
69
|
*/
|
|
69
|
-
export async function dispatchTool(toolName, args,
|
|
70
|
+
export async function dispatchTool(toolName, args, ctx = {}) {
|
|
70
71
|
switch (toolName) {
|
|
71
72
|
// ── get_sample ────────────────────────────────────────────────────────────
|
|
72
73
|
case "get_sample": {
|
|
@@ -854,17 +855,8 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
854
855
|
}
|
|
855
856
|
// ── generate_3d_model ────────────────────────────────────────────────────
|
|
856
857
|
case "generate_3d_model": {
|
|
857
|
-
const genResult = await
|
|
858
|
-
|
|
859
|
-
imageUrl: args?.imageUrl,
|
|
860
|
-
quality: args?.quality,
|
|
861
|
-
provider: args?.provider,
|
|
862
|
-
});
|
|
863
|
-
const genText = formatGenerateResult(genResult);
|
|
864
|
-
return {
|
|
865
|
-
content: withDisclaimer([{ type: "text", text: genText }]),
|
|
866
|
-
isError: genResult.ok ? undefined : true,
|
|
867
|
-
};
|
|
858
|
+
const genResult = await runGenerate3dModel(args, ctx);
|
|
859
|
+
return { ...genResult, content: withDisclaimer(genResult.content) };
|
|
868
860
|
}
|
|
869
861
|
// ── analyze_project ───────────────────────────────────────────────────────
|
|
870
862
|
case "analyze_project": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sceneview-mcp",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"mcpName": "io.github.sceneview/mcp",
|
|
5
5
|
"description": "MCP server for SceneView, the 3D & AR SDK for Android and the web. Gives your AI coding assistant the full SceneView SDK so it writes correct, compilable code.",
|
|
6
6
|
"keywords": [
|
|
@@ -61,12 +61,13 @@
|
|
|
61
61
|
"node": ">=18"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
|
-
"
|
|
64
|
+
"sync-vertical-versions": "node packages/shared/generate-sceneview-version.mjs",
|
|
65
|
+
"prebuild": "npm run sync-vertical-versions && node scripts/generate-llms-txt.js && node scripts/generate-version.js && node scripts/generate-symbols.js",
|
|
65
66
|
"build": "tsc",
|
|
66
|
-
"prepare": "node scripts/generate-llms-txt.js && node scripts/generate-version.js && node scripts/generate-symbols.js && tsc",
|
|
67
|
+
"prepare": "npm run sync-vertical-versions && node scripts/generate-llms-txt.js && node scripts/generate-version.js && node scripts/generate-symbols.js && tsc",
|
|
67
68
|
"start": "node dist/index.js",
|
|
68
69
|
"dev": "tsx src/index.ts",
|
|
69
|
-
"test": "node scripts/generate-llms-txt.js && node scripts/generate-version.js && node scripts/generate-symbols.js && vitest run",
|
|
70
|
+
"test": "npm run sync-vertical-versions && node scripts/generate-llms-txt.js && node scripts/generate-version.js && node scripts/generate-symbols.js && vitest run",
|
|
70
71
|
"lint": "cd .. && mcp/node_modules/.bin/biome check mcp/src mcp/scripts",
|
|
71
72
|
"lint:fix": "cd .. && mcp/node_modules/.bin/biome check --write mcp/src mcp/scripts",
|
|
72
73
|
"deploy": "npm run build && wrangler deploy"
|