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
package/README.md
CHANGED
|
@@ -210,8 +210,8 @@ Any client that accepts a Streamable HTTP MCP URL can use it. In claude.ai, that
|
|
|
210
210
|
**Authless and read-only.** There is no sign-in, no API key and no account: every tool is a pure
|
|
211
211
|
function of the SDK's own documentation, samples and API surface, so there is nothing to
|
|
212
212
|
authenticate and nothing of yours stored. All tools are annotated `readOnlyHint` except
|
|
213
|
-
`generate_3d_model`, which
|
|
214
|
-
open-world
|
|
213
|
+
`generate_3d_model`, which can call an external generation service and write a GLB to a local
|
|
214
|
+
path you name (`save_to_path`), and is therefore marked open-world and not read-only.
|
|
215
215
|
|
|
216
216
|
**Prefer it local?** `npx -y sceneview-mcp` runs the exact same server over stdio. The local
|
|
217
217
|
route is the one that reads your project from disk (`analyze_project`) and the one that accepts
|
|
@@ -318,7 +318,7 @@ Six tools carry most of what assistants actually do with SceneView. If you read
|
|
|
318
318
|
| Tool | What it does |
|
|
319
319
|
|---|---|
|
|
320
320
|
| `search_models` | Searches Sketchfab for free 3D models (BYOK — set `SKETCHFAB_API_KEY`) |
|
|
321
|
-
| `generate_3d_model` | Generates a brand-new GLB
|
|
321
|
+
| `generate_3d_model` | Generates a brand-new GLB at real-world scale (metres): deterministic parametric primitives with no key, or a text prompt / image via TRELLIS.2 on Runware or Tripo AI (BYOK — set `RUNWARE_API_KEY` or `TRIPO_API_KEY`). Optional `targetSize` and `save_to_path` |
|
|
322
322
|
| `analyze_project` | Scans a local SceneView project on disk — detects platform, extracts version, flags outdated deps and known anti-patterns |
|
|
323
323
|
| `search_android_docs` | Searches Google's stock Android docs knowledge base (needs the `android` CLI on PATH) |
|
|
324
324
|
| `fetch_android_doc` | Fetches a full Android docs entry by its `kb://...` URI (needs the `android` CLI on PATH) |
|
|
@@ -368,7 +368,37 @@ Call it like `search_models({ query: "red sports car", category: "cars-vehicles"
|
|
|
368
368
|
|
|
369
369
|
## `generate_3d_model` — create brand-new 3D assets from the AI
|
|
370
370
|
|
|
371
|
-
When no existing model fits, `generate_3d_model` closes the other half of the asset loop: it generates a fresh GLB from a **text prompt** (text→3D) or a **source image** (image→3D)
|
|
371
|
+
When no existing model fits, `generate_3d_model` closes the other half of the asset loop: it generates a fresh GLB from a **structured list of primitives** (parametric), a **text prompt** (text→3D) or a **source image** (image→3D) — ready for `rememberModelInstance(modelLoader, ...)` and AR placement.
|
|
372
|
+
|
|
373
|
+
Everything here is free on SceneView's side: there is no paid tier and no SceneView-hosted generation API. The parametric mode runs locally with no key; the AI modes use your own provider key and are billed by that provider.
|
|
374
|
+
|
|
375
|
+
### Parametric mode — no key, no network
|
|
376
|
+
|
|
377
|
+
`provider: "parametric"` (or just passing `parts`) builds a deterministic GLB from primitives — `box`, `cylinder` (with optional `radiusTop`), `cone`, `sphere`, `torus` — each with a size, a centre `position`, an Euler `rotation` in degrees and a `"#rrggbb"` colour. Parts are combined by composition (one node per part, no boolean subtraction), up to 64 per model. Sizes are given in `units` (`m` by default, or `cm`, `mm`, `in`, `ft`) and the GLB is always written in metres. The same description always gives the same bytes, which makes it a good fit for blockouts, placeholders and furniture whose dimensions are known:
|
|
378
|
+
|
|
379
|
+
```js
|
|
380
|
+
generate_3d_model({
|
|
381
|
+
units: "cm",
|
|
382
|
+
parts: [
|
|
383
|
+
{ shape: "box", size: [120, 4, 60], position: [0, 73, 0], color: "#8b5a2b" },
|
|
384
|
+
{ shape: "cylinder", radius: 2, height: 71, position: [-55, 35.5, -25] },
|
|
385
|
+
{ shape: "cylinder", radius: 2, height: 71, position: [55, 35.5, -25] },
|
|
386
|
+
{ shape: "cylinder", radius: 2, height: 71, position: [-55, 35.5, 25] },
|
|
387
|
+
{ shape: "cylinder", radius: 2, height: 71, position: [55, 35.5, 25] },
|
|
388
|
+
],
|
|
389
|
+
save_to_path: "/absolute/path/to/app/src/main/assets/models/desk.glb",
|
|
390
|
+
})
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Without `save_to_path`, the parametric GLB (up to 512 KB) comes back base64-encoded in `structuredContent.glbBase64`. Parametric mode also works on the hosted connector, which cannot write to your disk.
|
|
394
|
+
|
|
395
|
+
### Real-world scale and `save_to_path` (every mode)
|
|
396
|
+
|
|
397
|
+
- **Units.** glTF's unit is the metre, and SceneView renders 1 unit as 1 m. Every result reports the model's bounding-box size in metres (`dimensions`, `bounds`, `units: "meters"`).
|
|
398
|
+
- **`targetSize`.** Set exactly one of `heightMeters`, `widthMeters`, `depthMeters` or `maxDimensionMeters` and the model is scaled uniformly so that dimension matches (AI meshes usually come out about one unit across). The scale is applied on a new root node, so compressed or quantized meshes are left intact; the result reports the scale factor and the original size.
|
|
399
|
+
- **`save_to_path`.** An absolute path to a `.glb` file. The parent directory must already exist, `..` segments, symlinks and directories are refused, and an existing file is never replaced unless you pass `overwrite: true`. The path is checked *before* any generation runs, so a bad path never costs provider credits. In AI modes the tool downloads the provider's GLB immediately (so the expiring URL no longer matters), applies `targetSize` if given, and writes it. Only the local package (`npx -y sceneview-mcp`) accepts `save_to_path`.
|
|
400
|
+
|
|
401
|
+
### AI modes — bring your own key
|
|
372
402
|
|
|
373
403
|
Two providers, both bring-your-own-key:
|
|
374
404
|
|
|
@@ -403,9 +433,9 @@ Tripo's two quality tiers:
|
|
|
403
433
|
}
|
|
404
434
|
```
|
|
405
435
|
|
|
406
|
-
Call it like `generate_3d_model({ prompt: "a low-poly cactus in a striped pot" })` or `generate_3d_model({ imageUrl: "https://example.com/chair.jpg", quality: "hd", provider: "trellis" })`. Provide exactly one of `prompt` / `imageUrl`.
|
|
436
|
+
Call it like `generate_3d_model({ prompt: "a low-poly cactus in a striped pot" })` or `generate_3d_model({ imageUrl: "https://example.com/chair.jpg", quality: "hd", provider: "trellis", targetSize: { heightMeters: 0.9 }, save_to_path: "/abs/path/chair.glb" })`. Provide exactly one of `prompt` / `imageUrl`.
|
|
407
437
|
|
|
408
|
-
**⚠️
|
|
438
|
+
**⚠️ Without `save_to_path`, the GLB download URL is temporary (Tripo: ~5 minutes)** — download the file immediately and self-host it (e.g. copy it into your app's `assets/models/`). The tool result repeats this warning. Missing key, task failures, rate limits, and poll timeouts (2 min fast / 4 min hd cap) all return clear, actionable messages instead of hanging or crashing.
|
|
409
439
|
|
|
410
440
|
## `analyze_project` — local project scan
|
|
411
441
|
|
|
@@ -476,7 +506,7 @@ The MCP server is tested with **2,015 unit tests** across 91 test files covering
|
|
|
476
506
|
Tests 2015 passed (2015)
|
|
477
507
|
```
|
|
478
508
|
|
|
479
|
-
All tools work **fully offline** except `sceneview://known-issues` (GitHub API, cached 10 min), `search_models` (Sketchfab, BYOK), and `generate_3d_model` (Tripo AI, BYOK). Anonymous telemetry also makes a network call unless `SCENEVIEW_TELEMETRY=0` (see [below](#anonymous-telemetry)).
|
|
509
|
+
All tools work **fully offline** except `sceneview://known-issues` (GitHub API, cached 10 min), `search_models` (Sketchfab, BYOK), and `generate_3d_model` in its AI modes (TRELLIS.2 / Tripo AI, BYOK; the parametric mode is offline). Anonymous telemetry also makes a network call unless `SCENEVIEW_TELEMETRY=0` (see [below](#anonymous-telemetry)).
|
|
480
510
|
|
|
481
511
|
---
|
|
482
512
|
|
|
@@ -500,7 +530,7 @@ Install Node.js from [nodejs.org](https://nodejs.org/) (LTS recommended). npm an
|
|
|
500
530
|
|
|
501
531
|
### Firewall or proxy issues
|
|
502
532
|
|
|
503
|
-
The only network calls are to the GitHub API (for known issues), Sketchfab (when `SKETCHFAB_API_KEY` is set), Tripo AI or Runware (when `TRIPO_API_KEY` / `RUNWARE_API_KEY` is set and `generate_3d_model` is called), and the anonymous telemetry endpoint (off with `SCENEVIEW_TELEMETRY=0`). Everything else works offline.
|
|
533
|
+
The only network calls are to the GitHub API (for known issues), Sketchfab (when `SKETCHFAB_API_KEY` is set), Tripo AI or Runware (when `TRIPO_API_KEY` / `RUNWARE_API_KEY` is set and `generate_3d_model` is called in an AI mode, plus the download of the generated GLB when `targetSize` or `save_to_path` is used), and the anonymous telemetry endpoint (off with `SCENEVIEW_TELEMETRY=0`). Everything else works offline.
|
|
504
534
|
|
|
505
535
|
```json
|
|
506
536
|
{
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output stage of `generate_3d_model`, shared by every mode (parametric,
|
|
3
|
+
* TRELLIS.2, Tripo):
|
|
4
|
+
*
|
|
5
|
+
* - real-world scale: measure the GLB (metres, glTF's unit) and, when the
|
|
6
|
+
* caller gives a target size, rescale it uniformly so that one dimension
|
|
7
|
+
* matches exactly;
|
|
8
|
+
* - `save_to_path`: write the GLB to a local file the caller names, after
|
|
9
|
+
* validating the path, never overwriting an existing file unless asked.
|
|
10
|
+
*
|
|
11
|
+
* The path is validated BEFORE any generation runs, so a bad path never
|
|
12
|
+
* costs provider credits.
|
|
13
|
+
*/
|
|
14
|
+
import * as path from "node:path";
|
|
15
|
+
import { dimensionsOf, GlbError, measureGlb, parseGlb, scaleGlbDocument, writeGlb, } from "./glb.js";
|
|
16
|
+
const TARGET_KEYS = ["heightMeters", "widthMeters", "depthMeters", "maxDimensionMeters"];
|
|
17
|
+
/** Largest accepted target, in metres (a building, not a planet). */
|
|
18
|
+
const MAX_TARGET_METERS = 1000;
|
|
19
|
+
/** Validate `targetSize`. Returns the key + value, or an error message. */
|
|
20
|
+
export function parseTargetSize(value) {
|
|
21
|
+
if (value === undefined || value === null)
|
|
22
|
+
return null;
|
|
23
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
24
|
+
return { error: "`targetSize` must be an object such as { heightMeters: 0.75 }." };
|
|
25
|
+
}
|
|
26
|
+
const entries = Object.entries(value).filter(([, v]) => v !== undefined);
|
|
27
|
+
if (entries.length !== 1 || !TARGET_KEYS.includes(entries[0][0])) {
|
|
28
|
+
return {
|
|
29
|
+
error: `\`targetSize\` must set exactly one of: ${TARGET_KEYS.join(", ")}.`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const [key, meters] = entries[0];
|
|
33
|
+
if (typeof meters !== "number" ||
|
|
34
|
+
!Number.isFinite(meters) ||
|
|
35
|
+
meters <= 0 ||
|
|
36
|
+
meters > MAX_TARGET_METERS) {
|
|
37
|
+
return {
|
|
38
|
+
error: `\`targetSize.${key}\` must be a number of metres between 0 and ${MAX_TARGET_METERS}.`,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { key, meters };
|
|
42
|
+
}
|
|
43
|
+
function round(v) {
|
|
44
|
+
return Math.round(v * 1e6) / 1e6;
|
|
45
|
+
}
|
|
46
|
+
function roundDims(d) {
|
|
47
|
+
return { width: round(d.width), height: round(d.height), depth: round(d.depth) };
|
|
48
|
+
}
|
|
49
|
+
function axisOf(key, dims) {
|
|
50
|
+
switch (key) {
|
|
51
|
+
case "heightMeters":
|
|
52
|
+
return dims.height;
|
|
53
|
+
case "widthMeters":
|
|
54
|
+
return dims.width;
|
|
55
|
+
case "depthMeters":
|
|
56
|
+
return dims.depth;
|
|
57
|
+
default:
|
|
58
|
+
return Math.max(dims.width, dims.height, dims.depth);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Measure a GLB and, when `target` is set, rescale it uniformly so the
|
|
63
|
+
* targeted dimension equals `target.meters`. Without a target the bytes are
|
|
64
|
+
* returned unchanged, with their measured size.
|
|
65
|
+
*/
|
|
66
|
+
export function normalizeGlbScale(glb, target) {
|
|
67
|
+
let parsed;
|
|
68
|
+
try {
|
|
69
|
+
parsed = parseGlb(glb);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
const cause = err instanceof GlbError ? err.message : String(err);
|
|
73
|
+
return { ok: false, message: `The generated file is not a usable GLB: ${cause}` };
|
|
74
|
+
}
|
|
75
|
+
const bounds = measureGlb(parsed.json);
|
|
76
|
+
if (!bounds) {
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
message: "The GLB has no measurable geometry (no POSITION min/max), so its real-world size cannot be reported.",
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const original = dimensionsOf(bounds);
|
|
83
|
+
if (!target) {
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
glb,
|
|
87
|
+
scale: {
|
|
88
|
+
units: "meters",
|
|
89
|
+
originalDimensions: roundDims(original),
|
|
90
|
+
dimensions: roundDims(original),
|
|
91
|
+
bounds: { min: bounds.min.map(round), max: bounds.max.map(round) },
|
|
92
|
+
scaleFactor: 1,
|
|
93
|
+
target: null,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const current = axisOf(target.key, original);
|
|
98
|
+
if (!(current > 0)) {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
message: `The model is flat along the dimension \`${target.key}\` targets, so it cannot be scaled to it.`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const factor = target.meters / current;
|
|
105
|
+
const scaledJson = scaleGlbDocument(parsed.json, factor);
|
|
106
|
+
const scaledBounds = measureGlb(scaledJson) ?? bounds;
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
glb: writeGlb(scaledJson, parsed.bin),
|
|
110
|
+
scale: {
|
|
111
|
+
units: "meters",
|
|
112
|
+
originalDimensions: roundDims(original),
|
|
113
|
+
dimensions: roundDims(dimensionsOf(scaledBounds)),
|
|
114
|
+
bounds: { min: scaledBounds.min.map(round), max: scaledBounds.max.map(round) },
|
|
115
|
+
scaleFactor: round(factor),
|
|
116
|
+
target,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// ─── Provider download ──────────────────────────────────────────────────────
|
|
121
|
+
/** Provider GLBs are a few MB; refuse anything absurd. */
|
|
122
|
+
export const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
123
|
+
const DOWNLOAD_TIMEOUT_MS = 60_000;
|
|
124
|
+
/** Download a provider GLB (https only, bounded size and time). */
|
|
125
|
+
export async function downloadGlb(url) {
|
|
126
|
+
if (!/^https:\/\//i.test(url)) {
|
|
127
|
+
return {
|
|
128
|
+
ok: false,
|
|
129
|
+
message: "The provider returned a non-https model URL; not downloading it.",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
let response;
|
|
133
|
+
try {
|
|
134
|
+
response = await fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
138
|
+
return { ok: false, message: `Could not download the generated GLB (${cause}).` };
|
|
139
|
+
}
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
return {
|
|
142
|
+
ok: false,
|
|
143
|
+
message: `Downloading the generated GLB failed (HTTP ${response.status}).`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const declared = Number(response.headers?.get?.("content-length") ?? 0);
|
|
147
|
+
if (declared > MAX_DOWNLOAD_BYTES) {
|
|
148
|
+
return { ok: false, message: `The generated GLB is larger than ${MAX_DOWNLOAD_BYTES} bytes.` };
|
|
149
|
+
}
|
|
150
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
151
|
+
if (bytes.length > MAX_DOWNLOAD_BYTES) {
|
|
152
|
+
return { ok: false, message: `The generated GLB is larger than ${MAX_DOWNLOAD_BYTES} bytes.` };
|
|
153
|
+
}
|
|
154
|
+
return { ok: true, glb: bytes };
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validate a `save_to_path` before anything is generated:
|
|
158
|
+
* - an absolute path (the MCP server's working directory is not the
|
|
159
|
+
* user's, so a relative path would land somewhere surprising);
|
|
160
|
+
* - ending in `.glb`, with no `..` segment and no NUL byte;
|
|
161
|
+
* - whose parent directory already exists (nothing is created);
|
|
162
|
+
* - that is not an existing directory or symlink, and not an existing
|
|
163
|
+
* file unless `overwrite` is true.
|
|
164
|
+
*/
|
|
165
|
+
export async function checkSavePath(raw, overwrite) {
|
|
166
|
+
if (typeof raw !== "string" || raw.trim() === "") {
|
|
167
|
+
return { ok: false, message: "`save_to_path` must be a non-empty string." };
|
|
168
|
+
}
|
|
169
|
+
const value = raw.trim();
|
|
170
|
+
if (value.includes("\0")) {
|
|
171
|
+
return { ok: false, message: "`save_to_path` contains a NUL byte." };
|
|
172
|
+
}
|
|
173
|
+
if (!path.isAbsolute(value)) {
|
|
174
|
+
return {
|
|
175
|
+
ok: false,
|
|
176
|
+
message: `\`save_to_path\` must be an absolute path (got "${value}"). The MCP server's working directory is not your project's, so relative paths are refused.`,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (value.split(/[\\/]/).includes("..")) {
|
|
180
|
+
return { ok: false, message: "`save_to_path` must not contain `..` segments." };
|
|
181
|
+
}
|
|
182
|
+
if (path.extname(value).toLowerCase() !== ".glb") {
|
|
183
|
+
return { ok: false, message: "`save_to_path` must end in `.glb`." };
|
|
184
|
+
}
|
|
185
|
+
const target = path.resolve(value);
|
|
186
|
+
const fs = await import("node:fs/promises");
|
|
187
|
+
try {
|
|
188
|
+
const parent = await fs.stat(path.dirname(target));
|
|
189
|
+
if (!parent.isDirectory()) {
|
|
190
|
+
return { ok: false, message: `The parent of \`save_to_path\` is not a directory.` };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return {
|
|
195
|
+
ok: false,
|
|
196
|
+
message: `The directory ${path.dirname(target)} does not exist. Create it first; save_to_path never creates directories.`,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const existing = await fs.lstat(target);
|
|
201
|
+
if (existing.isSymbolicLink()) {
|
|
202
|
+
return { ok: false, message: `${target} is a symbolic link; refusing to write through it.` };
|
|
203
|
+
}
|
|
204
|
+
if (!existing.isFile()) {
|
|
205
|
+
return { ok: false, message: `${target} exists and is not a regular file.` };
|
|
206
|
+
}
|
|
207
|
+
if (!overwrite) {
|
|
208
|
+
return {
|
|
209
|
+
ok: false,
|
|
210
|
+
message: `${target} already exists. Pass \`overwrite: true\` to replace it, or choose another path.`,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
catch (err) {
|
|
215
|
+
if (err.code !== "ENOENT") {
|
|
216
|
+
return { ok: false, message: `Cannot inspect ${target}: ${err.message}` };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return { ok: true, path: target };
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Write the GLB. Without `overwrite`, the file is opened exclusively (`wx`),
|
|
223
|
+
* so a file that appeared since the check is still never clobbered.
|
|
224
|
+
*/
|
|
225
|
+
export async function writeGlbFile(target, glb, overwrite) {
|
|
226
|
+
const fs = await import("node:fs/promises");
|
|
227
|
+
try {
|
|
228
|
+
await fs.writeFile(target, glb, { flag: overwrite ? "w" : "wx" });
|
|
229
|
+
return { ok: true, bytes: glb.length };
|
|
230
|
+
}
|
|
231
|
+
catch (err) {
|
|
232
|
+
const code = err.code;
|
|
233
|
+
if (code === "EEXIST") {
|
|
234
|
+
return {
|
|
235
|
+
ok: false,
|
|
236
|
+
message: `${target} already exists. Pass \`overwrite: true\` to replace it.`,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
return { ok: false, message: `Could not write ${target}: ${err.message}` };
|
|
240
|
+
}
|
|
241
|
+
}
|