sceneview-mcp 4.2.0 → 4.3.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.
@@ -0,0 +1,55 @@
1
+ function validateSpec(spec) {
2
+ if (spec.v !== 1)
3
+ throw new Error("Spatial answer v must be 1.");
4
+ if (spec.object?.kind !== "box" ||
5
+ !Array.isArray(spec.object.sizeM) ||
6
+ spec.object.sizeM.length !== 3 ||
7
+ spec.object.sizeM.some((s) => typeof s !== "number" || !Number.isFinite(s) || s <= 0.01 || s > 10)) {
8
+ throw new Error("Each box size must be a finite number greater than 0.01 and at most 10 metres (greater than 1 and at most 1000 cm).");
9
+ }
10
+ if (typeof spec.label !== "string" || Array.from(spec.label).length > 60) {
11
+ throw new Error("label must be a string of at most 60 characters.");
12
+ }
13
+ if (spec.placement !== "floor" && spec.placement !== "table") {
14
+ throw new Error('placement must be "floor" or "table".');
15
+ }
16
+ if (!["user", "estimated", "measured"].includes(spec.dimensionSource)) {
17
+ throw new Error('dimensionSource must be "user", "estimated" or "measured".');
18
+ }
19
+ }
20
+ /** Convert centimetres supplied by the assistant into the shared app spec. */
21
+ export function buildSpatialAnswerSpec(input) {
22
+ const sizes = [input.widthCm, input.heightCm, input.depthCm];
23
+ if (sizes.some((s) => typeof s !== "number" || !Number.isFinite(s) || s <= 1 || s > 1000)) {
24
+ throw new Error("widthCm, heightCm and depthCm must each be a finite number greater than 1 and at most 1000 cm.");
25
+ }
26
+ const dimensionSource = input.dimensionSource === undefined ? "user" : input.dimensionSource;
27
+ if (dimensionSource !== "user" && dimensionSource !== "estimated") {
28
+ throw new Error('dimensionSource must be "user" or "estimated".');
29
+ }
30
+ const spec = {
31
+ v: 1,
32
+ object: {
33
+ kind: "box",
34
+ sizeM: sizes.map((s) => s / 100),
35
+ },
36
+ dimensionSource,
37
+ placement: (input.placement === undefined
38
+ ? "floor"
39
+ : input.placement),
40
+ label: input.label,
41
+ };
42
+ validateSpec(spec);
43
+ return spec;
44
+ }
45
+ /** UTF-8 JSON, base64url without padding; enforce the app's payload limit. */
46
+ export function encodeSpatialAnswer(spec) {
47
+ validateSpec(spec);
48
+ const encoded = Buffer.from(JSON.stringify(spec), "utf8").toString("base64url");
49
+ if (encoded.length > 2048)
50
+ throw new Error("Encoded spatial answer payload must be at most 2048 characters.");
51
+ return encoded;
52
+ }
53
+ export function spatialAnswerUrl(spec) {
54
+ return `https://sceneview.github.io/open?demo=spatial-answer&answer=${encodeSpatialAnswer(spec)}`;
55
+ }
@@ -772,6 +772,69 @@ export const TOOL_DEFINITIONS = [
772
772
  title: "Fetch an Android doc",
773
773
  },
774
774
  },
775
+ {
776
+ name: "show_in_space",
777
+ description: "Use when the user wants to see an object of given size in their room at real scale: furniture, a box, a parcel or a TV. Returns one link opening the Spatial answer in the SceneView Android app; without the app, the web page shows the size and offers the app. Represents the object's bounding box using the sizes the user said (dimensionSource: user) or the assistant estimated (estimated). No fit detection and no accuracy claim. Dimensions are width, height, depth in centimetres.",
778
+ inputSchema: {
779
+ type: "object",
780
+ properties: {
781
+ widthCm: {
782
+ type: "number",
783
+ exclusiveMinimum: 1,
784
+ maximum: 1000,
785
+ description: "Width in centimetres, left to right as you face the object (a desk's length).",
786
+ },
787
+ heightCm: {
788
+ type: "number",
789
+ exclusiveMinimum: 1,
790
+ maximum: 1000,
791
+ description: "Height in centimetres, from the floor or table up.",
792
+ },
793
+ depthCm: {
794
+ type: "number",
795
+ exclusiveMinimum: 1,
796
+ maximum: 1000,
797
+ description: "Depth in centimetres, front to back.",
798
+ },
799
+ label: {
800
+ type: "string",
801
+ maxLength: 60,
802
+ description: 'Short name shown with the box, e.g. "Desk" or "55-inch TV".',
803
+ },
804
+ placement: {
805
+ type: "string",
806
+ enum: ["floor", "table"],
807
+ default: "floor",
808
+ description: "Where the object stands: on the floor (furniture) or on a table (a parcel, a speaker).",
809
+ },
810
+ dimensionSource: {
811
+ type: "string",
812
+ enum: ["user", "estimated"],
813
+ default: "user",
814
+ description: '"user" when the user gave the sizes, "estimated" when you estimated them (say so in your answer).',
815
+ },
816
+ },
817
+ required: ["widthCm", "heightCm", "depthCm", "label"],
818
+ additionalProperties: false,
819
+ },
820
+ outputSchema: {
821
+ type: "object",
822
+ properties: {
823
+ url: { type: "string" },
824
+ label: { type: "string" },
825
+ sizeCm: { type: "array", items: { type: "number" }, minItems: 3, maxItems: 3 },
826
+ placement: { type: "string", enum: ["floor", "table"] },
827
+ },
828
+ required: ["url", "label", "sizeCm", "placement"],
829
+ additionalProperties: false,
830
+ },
831
+ annotations: {
832
+ readOnlyHint: true,
833
+ openWorldHint: false,
834
+ destructiveHint: false,
835
+ title: "Show in space",
836
+ },
837
+ },
775
838
  {
776
839
  name: "view_3d_model",
777
840
  description: "Render an interactive 3D model viewer inline in the conversation. Pass a public GLB / GLTF / 3MF URL and the assistant will display it in a SceneView-branded widget with orbit controls, auto-rotate, and AR mode (where supported). Use this when the user asks to PREVIEW a 3D model, asks 'what does X look like in 3D?', after `search_models` to render the chosen result, or to show a `.3mf` you just produced for 3D printing — the widget converts 3MF to glTF in the browser, so a printable model is previewable without any download.",
@@ -35,6 +35,7 @@ import { getPlatformSetup } from "../platform-setup.js";
35
35
  import { buildPreviewUrl, formatPreviewResponse, validatePreviewInput } from "../preview.js";
36
36
  import { getSample, SAMPLES } from "../samples.js";
37
37
  import { formatSearchResults, searchModels } from "../search-models.js";
38
+ import { buildSpatialAnswerSpec, spatialAnswerUrl } from "../spatial-answer-link.js";
38
39
  import { formatValidationReport, validateCode } from "../validator.js";
39
40
  import { WIDGET_3D_VIEWER_URI } from "../widgets.js";
40
41
  // ─── Legal disclaimer (identical to index.ts 4.0.0) ─────────────────────
@@ -87,7 +88,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
87
88
  ? [
88
89
  `**SPM dependency:**`,
89
90
  `\`\`\`swift`,
90
- `.package(url: "${sample.spmDependency ?? sample.dependency}", from: "${LATEST_SCENEVIEW_RELEASE}")`,
91
+ `.package(url: "${sample.spmDependency ?? sample.dependency}", exact: "4.68.0")`,
91
92
  `\`\`\``,
92
93
  ]
93
94
  : [
@@ -292,7 +293,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
292
293
  `\`\`\``,
293
294
  `https://github.com/sceneview/sceneview`,
294
295
  `\`\`\``,
295
- `Set version rule to **"from: ${LATEST_SCENEVIEW_RELEASE}"**.`,
296
+ `Set version rule to **"Exact Version 4.68.0"**.`,
296
297
  ``,
297
298
  `Or in Package.swift:`,
298
299
  `\`\`\`swift`,
@@ -303,7 +304,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
303
304
  ` name: "MyApp",`,
304
305
  ` platforms: [.iOS(.v17), .macOS(.v14), .visionOS(.v1)],`,
305
306
  ` dependencies: [`,
306
- ` .package(url: "https://github.com/sceneview/sceneview", from: "${LATEST_SCENEVIEW_RELEASE}")`,
307
+ ` .package(url: "https://github.com/sceneview/sceneview", exact: "4.68.0")`,
307
308
  ` ],`,
308
309
  ` targets: [`,
309
310
  ` .executableTarget(`,
@@ -374,7 +375,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
374
375
  `### 1. Add SPM Dependency`,
375
376
  ``,
376
377
  `\`\`\`swift`,
377
- `.package(url: "https://github.com/sceneview/sceneview", from: "${LATEST_SCENEVIEW_RELEASE}")`,
378
+ `.package(url: "https://github.com/sceneview/sceneview", exact: "4.68.0")`,
378
379
  `\`\`\``,
379
380
  ``,
380
381
  `### 2. Minimum Platform`,
@@ -663,7 +664,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
663
664
  }
664
665
  // ── list_platforms ────────────────────────────────────────────────────────
665
666
  case "list_platforms": {
666
- // All `version:` and `dependency:` fields use `LATEST_SCENEVIEW_RELEASE`
667
+ // Maintained `version:` and `dependency:` fields use `LATEST_SCENEVIEW_RELEASE`
667
668
  // explicitly so each platform row renders the actually-current SDK
668
669
  // version. Pre-fix these were double-quoted strings with a literal
669
670
  // `${LATEST_SCENEVIEW_RELEASE}` substring that never interpolated —
@@ -708,8 +709,8 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
708
709
  platform: "iOS",
709
710
  renderer: "RealityKit",
710
711
  framework: "SwiftUI",
711
- status: "Alpha",
712
- version: LATEST_SCENEVIEW_RELEASE,
712
+ status: "End of life at 4.68.0",
713
+ version: "4.68.0",
713
714
  dependency: "SceneViewSwift (SPM)",
714
715
  features: ["3D", "AR (ARKit)", `${IOS_NODE_TYPE_COUNT} node types`, "USDZ models"],
715
716
  },
@@ -717,8 +718,8 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
717
718
  platform: "macOS",
718
719
  renderer: "RealityKit",
719
720
  framework: "SwiftUI",
720
- status: "Alpha",
721
- version: LATEST_SCENEVIEW_RELEASE,
721
+ status: "End of life at 4.68.0",
722
+ version: "4.68.0",
722
723
  dependency: "SceneViewSwift (SPM)",
723
724
  features: ["3D", "Orbit camera", "USDZ models"],
724
725
  },
@@ -726,8 +727,8 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
726
727
  platform: "visionOS",
727
728
  renderer: "RealityKit",
728
729
  framework: "SwiftUI",
729
- status: "Alpha",
730
- version: LATEST_SCENEVIEW_RELEASE,
730
+ status: "End of life at 4.68.0",
731
+ version: "4.68.0",
731
732
  dependency: "SceneViewSwift (SPM)",
732
733
  features: ["3D", "Immersive spaces", "Hand tracking (planned)"],
733
734
  },
@@ -753,9 +754,18 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
753
754
  platform: "Flutter",
754
755
  renderer: "Filament / RealityKit",
755
756
  framework: "PlatformView",
756
- status: "Alpha",
757
- version: LATEST_SCENEVIEW_RELEASE,
758
- dependency: "flutter pub: flutter_sceneview (git ref until first publish, #2735)",
757
+ status: "End of life at 4.68.0",
758
+ version: "4.68.0",
759
+ dependency: "flutter_sceneview (4.68.0)",
760
+ features: ["3D", "AR", "Android + iOS bridge"],
761
+ },
762
+ {
763
+ platform: "React Native",
764
+ renderer: "Filament / RealityKit",
765
+ framework: "Fabric",
766
+ status: "End of life at 4.68.0",
767
+ version: "4.68.0",
768
+ dependency: "@sceneview-sdk/react-native@4.68.0",
759
769
  features: ["3D", "AR", "Android + iOS bridge"],
760
770
  },
761
771
  ];
@@ -915,6 +925,40 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
915
925
  isError: docResult.ok ? undefined : true,
916
926
  };
917
927
  }
928
+ case "show_in_space": {
929
+ try {
930
+ const spec = buildSpatialAnswerSpec({
931
+ widthCm: args?.widthCm,
932
+ heightCm: args?.heightCm,
933
+ depthCm: args?.depthCm,
934
+ label: args?.label,
935
+ placement: args?.placement,
936
+ dimensionSource: args?.dimensionSource,
937
+ });
938
+ const url = spatialAnswerUrl(spec);
939
+ const sizeCm = [args.widthCm, args.heightCm, args.depthCm];
940
+ return {
941
+ content: [
942
+ {
943
+ type: "text",
944
+ text: `${spec.label}: ${sizeCm.join(" × ")} cm — ${url}\nOpens at real scale in the SceneView app on Android; without the app, the page shows the size.`,
945
+ },
946
+ ],
947
+ structuredContent: { url, label: spec.label, sizeCm, placement: spec.placement },
948
+ };
949
+ }
950
+ catch (error) {
951
+ return {
952
+ isError: true,
953
+ content: [
954
+ {
955
+ type: "text",
956
+ text: `show_in_space: ${error instanceof Error ? error.message : String(error)}`,
957
+ },
958
+ ],
959
+ };
960
+ }
961
+ }
918
962
  // ── view_3d_model (MCP Apps widget) ──────────────────────────────────────
919
963
  //
920
964
  // Returns nothing the model must reason about beyond a one-line summary:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sceneview-mcp",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "mcpName": "io.github.sceneview/mcp",
5
5
  "description": "MCP server for SceneView — cross-platform 3D & AR SDK for Android and iOS. Gives your AI coding assistant the full SceneView SDK so it writes correct, compilable code.",
6
6
  "keywords": [
@@ -75,7 +75,7 @@
75
75
  "@modelcontextprotocol/sdk": "^1.29.0"
76
76
  },
77
77
  "devDependencies": {
78
- "@biomejs/biome": "^2.5.14",
78
+ "@biomejs/biome": "2.6.7",
79
79
  "@types/node": "^26.6.2",
80
80
  "tsx": "^4.0.0",
81
81
  "typescript": "^7.0.2",