sceneview-mcp 4.2.0 → 4.3.1

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 CHANGED
@@ -238,7 +238,7 @@ npx sceneview-mcp --http
238
238
 
239
239
  Configuration: `PORT` (default `3333`), `HOST` (default `127.0.0.1` — set `HOST=0.0.0.0` to expose it, and put HTTPS in front), `OPENAI_APPS_CHALLENGE_TOKEN` (the value OpenAI gives you when you submit the domain). CORS allows any origin. The usual `SKETCHFAB_API_KEY` / `TRIPO_API_KEY` / `RUNWARE_API_KEY` / `SCENEVIEW_TELEMETRY=0` knobs apply.
240
240
 
241
- **Everything is free, but not everything is remote.** Three generation tools (`render_3d_preview`, `create_3d_artifact`, `generate_scene`) need your own third-party credentials, which a shared anonymous endpoint cannot hold, so the remote surface omits them and refuses those names at call time with a clear `isError` message pointing at the local `npx sceneview-mcp` path. stdio lists and runs all 32.
241
+ **Everything is free, but not everything is remote.** Three generation tools (`render_3d_preview`, `create_3d_artifact`, `generate_scene`) need your own third-party credentials, which a shared anonymous endpoint cannot hold, so the remote surface omits them and refuses those names at call time with a clear `isError` message pointing at the local `npx sceneview-mcp` path. stdio lists and runs all 33.
242
242
 
243
243
  **Inline 3D viewer.** `view_3d_model` returns `structuredContent` plus `_meta.ui.resourceUri = ui://widget/3d-viewer.html`; the widget (SceneView.js + Filament.js, served by `resources/read` with the `text/html;profile=mcp-app` mime type and its `_meta.ui.csp`) renders the model inline in ChatGPT and any MCP Apps host.
244
244
 
@@ -327,6 +327,7 @@ Six tools carry most of what assistants actually do with SceneView. If you read
327
327
 
328
328
  | Tool | What it does |
329
329
  |---|---|
330
+ | `show_in_space` | Builds one link to show a box at real scale in the SceneView Android app, or its size on the web page with an app offer. Supply width, height and depth in cm, a label, optional floor/table placement and user/estimated dimension source. No fit detection or accuracy claim. Available locally and remotely. |
330
331
  | `view_3d_model` | Renders a public GLB / glTF URL in an interactive SceneView.js + Filament.js viewer inline in ChatGPT and any MCP Apps host (orbit, auto-rotate). For an https model it adds an "Open in AR on your phone" action (an `ar.sceneview.dev/open` link to the 3D AR Model Viewer app, with a QR code on desktop). Returns `structuredContent` + `_meta.ui.resourceUri` |
331
332
 
332
333
  ### 5 resources
@@ -2,7 +2,7 @@
2
2
  * analyze-project — local filesystem scan of a SceneView project.
3
3
  *
4
4
  * Because the SceneView MCP server runs on the user's machine, we can read
5
- * their project files directly: detect the platform (Android / iOS / Web),
5
+ * their project files directly: detect Android, Apple, Web, Flutter or React Native,
6
6
  * extract the SceneView dependency version, compare against the latest known
7
7
  * release, and scan source files for well-known anti-patterns (threading
8
8
  * violations, LightNode trailing-lambda bug, deprecated 2.x APIs, …).
@@ -31,6 +31,7 @@ import { LATEST_SCENEVIEW_RELEASE } from "./generated/version.js";
31
31
  * LLM that "4.0.0" was current even when the real SDK was at 4.0.9.
32
32
  */
33
33
  export const LATEST_SCENEVIEW_VERSION = LATEST_SCENEVIEW_RELEASE;
34
+ const LAST_RETIRED_PLATFORM_VERSION = "4.68.0";
34
35
  /** Hard cap on the number of source files inspected per call. */
35
36
  export const MAX_FILES_SCANNED = 30;
36
37
  /** Hard cap on total bytes read across all source files per call (500 KB). */
@@ -221,13 +222,13 @@ function extractSwiftVersion(contents) {
221
222
  return branchOrVersion[1];
222
223
  return null;
223
224
  }
224
- /** Extract the `sceneview-web` version from a `package.json`. */
225
- function extractNpmVersion(contents) {
225
+ /** Extract a supported dependency version from a `package.json`. */
226
+ function extractNpmVersion(contents, packageNames = ["sceneview-web", "@sceneview/sceneview-web"]) {
226
227
  try {
227
228
  const pkg = JSON.parse(contents);
228
229
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
229
230
  for (const [name, spec] of Object.entries(deps)) {
230
- if (name === "sceneview-web" || name === "@sceneview/sceneview-web") {
231
+ if (packageNames.includes(name)) {
231
232
  // Strip leading ^ / ~ / >= etc.
232
233
  const cleaned = spec.replace(/^[^\d]*/, "");
233
234
  const match = cleaned.match(/\d+\.\d+\.\d+(?:-[\w.]+)?/);
@@ -242,6 +243,27 @@ function extractNpmVersion(contents) {
242
243
  return null;
243
244
  }
244
245
  async function detectProject(rootDir) {
246
+ // Detect bridges before their native host projects so their package release
247
+ // remains independent of the maintained Android SDK.
248
+ const pubspec = await tryRead(rootDir, "pubspec.yaml");
249
+ const flutterDependency = pubspec?.contents.match(/^([ \t]+)flutter_sceneview:[ \t]*([^\n]*)(?:\n((?:\1[ \t]+[^\n]*(?:\n|$))*))?/m);
250
+ if (pubspec && flutterDependency) {
251
+ const inline = flutterDependency[2].match(/^["']?[\^~>= \t]*(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
252
+ const nested = flutterDependency[3]?.match(/\b(?:ref|version):[ \t]*["']?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)/);
253
+ return {
254
+ projectType: "flutter",
255
+ sceneViewVersion: inline?.[1] ?? nested?.[1] ?? null,
256
+ sourceFile: pubspec.path,
257
+ };
258
+ }
259
+ const packageJson = await tryRead(rootDir, "package.json");
260
+ if (packageJson && /"@sceneview-sdk\/react-native"\s*:/.test(packageJson.contents)) {
261
+ return {
262
+ projectType: "react-native",
263
+ sceneViewVersion: extractNpmVersion(packageJson.contents, ["@sceneview-sdk/react-native"]),
264
+ sourceFile: packageJson.path,
265
+ };
266
+ }
245
267
  // Android: build.gradle or build.gradle.kts anywhere reachable from root.
246
268
  // We first check the root for speed, then one level down for typical module layouts.
247
269
  const androidCandidates = [
@@ -273,7 +295,6 @@ async function detectProject(rootDir) {
273
295
  };
274
296
  }
275
297
  // Web: package.json referencing sceneview-web.
276
- const packageJson = await tryRead(rootDir, "package.json");
277
298
  if (packageJson && /"(?:@sceneview\/)?sceneview-web"/.test(packageJson.contents)) {
278
299
  return {
279
300
  projectType: "web",
@@ -285,11 +306,11 @@ async function detectProject(rootDir) {
285
306
  }
286
307
  // ─── Semver comparison (simple X.Y.Z) ────────────────────────────────────────
287
308
  /**
288
- * Returns `true` when `version` is strictly older than `LATEST_SCENEVIEW_VERSION`.
309
+ * Returns `true` when `version` is strictly older than the platform's last release.
289
310
  * Falls back to `false` (don't flag) if either side fails to parse cleanly —
290
311
  * we'd rather underreport than harass a user with a pre-release build.
291
312
  */
292
- function isVersionOutdated(version) {
313
+ function isVersionOutdated(version, latestVersion) {
293
314
  if (!version)
294
315
  return false;
295
316
  const parse = (v) => {
@@ -299,7 +320,7 @@ function isVersionOutdated(version) {
299
320
  return [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
300
321
  };
301
322
  const a = parse(version);
302
- const b = parse(LATEST_SCENEVIEW_VERSION);
323
+ const b = parse(latestVersion);
303
324
  if (!a || !b)
304
325
  return false;
305
326
  for (let i = 0; i < 3; i++) {
@@ -358,13 +379,16 @@ export async function analyzeProject(input = {}) {
358
379
  const detection = await detectProject(scannedPath);
359
380
  result.projectType = detection.projectType;
360
381
  result.sceneViewVersion = detection.sceneViewVersion;
361
- result.isOutdated = isVersionOutdated(detection.sceneViewVersion);
382
+ const retired = ["ios", "flutter", "react-native"].includes(detection.projectType);
383
+ result.latestVersion = retired ? LAST_RETIRED_PLATFORM_VERSION : LATEST_SCENEVIEW_VERSION;
384
+ result.isOutdated = isVersionOutdated(detection.sceneViewVersion, result.latestVersion);
362
385
  if (detection.projectType === "unknown") {
363
386
  result.warnings.push({
364
387
  file: scannedPath,
365
388
  type: "scan/no-sceneview-dependency",
366
389
  message: "No SceneView dependency was detected. Looked for `io.github.sceneview:sceneview` in " +
367
- "Gradle files, `SceneViewSwift` in `Package.swift`, and `sceneview-web` in `package.json`.",
390
+ "Gradle files, `SceneViewSwift` in `Package.swift`, `flutter_sceneview` in `pubspec.yaml`, " +
391
+ "and `sceneview-web` or `@sceneview-sdk/react-native` in `package.json`.",
368
392
  });
369
393
  }
370
394
  else if (!detection.sceneViewVersion) {
@@ -379,9 +403,13 @@ export async function analyzeProject(input = {}) {
379
403
  if (result.isOutdated && detection.sceneViewVersion) {
380
404
  result.suggestions.push({
381
405
  type: "suggestion/upgrade-sceneview",
382
- message: `You are on SceneView ${detection.sceneViewVersion}. The latest known release is ` +
383
- `${LATEST_SCENEVIEW_VERSION}. Consider upgrading — run \`get_migration_guide\` for ` +
384
- "the 2.x → 3.x migration notes, or `migrate_code` for automatic Kotlin rewrites.",
406
+ message: retired
407
+ ? `You are on SceneView ${detection.sceneViewVersion}. The last release for this ` +
408
+ `platform is ${result.latestVersion} (end of life; no new releases). ` +
409
+ "Published versions remain available for existing projects."
410
+ : `You are on SceneView ${detection.sceneViewVersion}. The latest known release is ` +
411
+ `${result.latestVersion}. Consider upgrading — run \`get_migration_guide\` for ` +
412
+ "the 2.x → 3.x migration notes, or `migrate_code` for automatic Kotlin rewrites.",
385
413
  });
386
414
  }
387
415
  // Step 2: anti-pattern scan (only if we have a known project type).
package/dist/discover.js CHANGED
@@ -76,9 +76,23 @@ export const DISCOVER_TTL_MS = 3_600_000;
76
76
  * Natural-language guidance, mirrored from the package description. Kept short
77
77
  * on purpose: per the spec it should not duplicate tool descriptions.
78
78
  */
79
- const DISCOVER_INSTRUCTIONS = "SceneView MCP — the full SceneView SDK (Android/Compose + Filament, iOS/SwiftUI + RealityKit, AR via ARCore/ARKit) " +
80
- "as tools and resources, so an AI writes correct, compilable SceneView code. Read the `sceneview://api` resource " +
81
- "before writing any SceneView code.";
79
+ /**
80
+ * What an agent should know before its first tool call. Sent in two places from
81
+ * this one string: the `initialize` result (`server.ts`, which most hosts put in
82
+ * the model's context at connect time) and `server/discover` below. Before this
83
+ * was wired into `initialize`, hosts that read server instructions got nothing.
84
+ * Keep it short: hosts place it in every conversation.
85
+ */
86
+ export const SERVER_INSTRUCTIONS = [
87
+ "SceneView MCP: the SceneView 3D & AR SDK (Android Jetpack Compose + Filament + ARCore, and the web) as tools and resources, so you write SceneView code that compiles on the first try.",
88
+ "Before writing SceneView code:",
89
+ "1. Read the `sceneview://api` resource. Use the 4.x names it lists; never emit a 2.x or Sceneform name from memory (`migrate_code` rewrites old code).",
90
+ "2. Start from `get_sample` or `get_setup` rather than from scratch.",
91
+ "3. Run `validate_code` on any Kotlin you show, and fix what it reports before answering.",
92
+ "Rules that break apps when missed: load models with `rememberModelInstance(modelLoader, path)` inside composables. Filament calls (`modelLoader.createModel*`, `materialLoader.*`) must run on the main thread, never from a background coroutine.",
93
+ "For a runtime error or a blank scene, call `debug_issue` or `get_troubleshooting`, and read `sceneview://known-issues`.",
94
+ ].join("\n");
95
+ const DISCOVER_INSTRUCTIONS = SERVER_INSTRUCTIONS;
82
96
  /**
83
97
  * Builds the `DiscoverResult`.
84
98
  *