sceneview-mcp 4.0.16 → 4.1.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 +246 -62
- package/dist/analyze-project.js +4 -2
- package/dist/artifact.js +38 -13
- package/dist/debug-issue.js +101 -19
- package/dist/discover.js +106 -0
- package/dist/extra-guides.js +3 -3
- package/dist/generate-scene.js +380 -61
- package/dist/generated/llms-txt.js +1 -1
- package/dist/generated/symbols.js +1030 -26
- package/dist/generated/version.js +12 -3
- package/dist/guides.js +10 -6
- package/dist/http.js +178 -0
- package/dist/index.js +34 -139
- package/dist/issues.js +1 -1
- package/dist/migrate-code.js +5 -3
- package/dist/platform-setup.js +33 -16
- package/dist/samples.js +31 -31
- package/dist/search-models.js +1 -1
- package/dist/server.js +197 -0
- package/dist/surfaces.js +32 -0
- package/dist/telemetry.js +14 -8
- package/dist/tools/definitions.js +176 -14
- package/dist/tools/handler.js +207 -66
- package/dist/tools/index.js +4 -4
- package/dist/tools/types.js +0 -4
- package/dist/validator.js +262 -161
- package/dist/widgets.js +915 -0
- package/package.json +16 -12
- package/dist/proxy.js +0 -176
- package/dist/tiers.js +0 -138
package/dist/tools/handler.js
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
* This module contains the full tool-handling logic extracted from
|
|
5
5
|
* `mcp/src/index.ts`. It has no dependency on the MCP stdio transport — it
|
|
6
6
|
* just takes a tool name + argument bag and returns a `ToolResult`. This
|
|
7
|
-
* lets the same logic be consumed by
|
|
8
|
-
*
|
|
9
|
-
* 1. The stdio MCP server in `../index.ts` (legacy npm package path).
|
|
10
|
-
* 2. The HTTP gateway in `mcp-gateway/src/mcp/registry.ts` (hosted path).
|
|
7
|
+
* lets the same logic be consumed by both the stdio MCP server in
|
|
8
|
+
* `../index.ts` and the Streamable HTTP server in `../server.ts`.
|
|
11
9
|
*
|
|
12
10
|
* Zero runtime behaviour change from 4.0.0: every tool returns exactly the
|
|
13
11
|
* same content it did when the logic lived inside the stdio server's
|
|
@@ -19,35 +17,39 @@
|
|
|
19
17
|
* `mcp/scripts/generate-llms-txt.js` keeps that file in sync with the
|
|
20
18
|
* canonical `llms.txt` at the repo root.
|
|
21
19
|
*/
|
|
22
|
-
import {
|
|
23
|
-
import { validateCode, formatValidationReport } from "../validator.js";
|
|
24
|
-
import { MIGRATION_GUIDE } from "../migration.js";
|
|
25
|
-
import { parseNodeSections, findNodeSection, listNodeTypes } from "../node-reference.js";
|
|
26
|
-
import { PLATFORM_ROADMAP, BEST_PRACTICES, AR_SETUP_GUIDE, TROUBLESHOOTING_GUIDE, } from "../guides.js";
|
|
27
|
-
import { buildPreviewUrl, validatePreviewInput, formatPreviewResponse, } from "../preview.js";
|
|
28
|
-
import { validateArtifactInput, generateArtifact, formatArtifactResponse, } from "../artifact.js";
|
|
29
|
-
import { getPlatformSetup, } from "../platform-setup.js";
|
|
30
|
-
import { migrateCode, formatMigrationResult } from "../migrate-code.js";
|
|
31
|
-
import { getDebugGuide, autoDetectIssue, DEBUG_CATEGORIES, } from "../debug-issue.js";
|
|
32
|
-
import { generateScene, formatGeneratedScene } from "../generate-scene.js";
|
|
33
|
-
import { ANIMATION_GUIDE, GESTURE_GUIDE, PERFORMANCE_TIPS, } from "../advanced-guides.js";
|
|
34
|
-
import { MATERIAL_GUIDE, COLLISION_GUIDE, MODEL_OPTIMIZATION_GUIDE, WEB_RENDERING_GUIDE, } from "../extra-guides.js";
|
|
35
|
-
import { searchModels, formatSearchResults } from "../search-models.js";
|
|
36
|
-
import { generateModel, formatGenerateResult } from "../generate-model.js";
|
|
20
|
+
import { ANIMATION_GUIDE, GESTURE_GUIDE, PERFORMANCE_TIPS } from "../advanced-guides.js";
|
|
37
21
|
import { analyzeProject, formatAnalysisReport } from "../analyze-project.js";
|
|
38
|
-
import {
|
|
22
|
+
import { fetchAndroidDoc, formatAndroidDocsFetch, formatAndroidDocsSearch, searchAndroidDocs, } from "../android-docs.js";
|
|
23
|
+
import { formatArtifactResponse, generateArtifact, validateArtifactInput, } from "../artifact.js";
|
|
24
|
+
import { autoDetectIssue, DEBUG_CATEGORIES, getDebugGuide, } from "../debug-issue.js";
|
|
25
|
+
import { COLLISION_GUIDE, MATERIAL_GUIDE, MODEL_OPTIMIZATION_GUIDE, WEB_RENDERING_GUIDE, } from "../extra-guides.js";
|
|
26
|
+
import { formatGenerateResult, generateModel } from "../generate-model.js";
|
|
27
|
+
import { formatGeneratedScene, generateScene } from "../generate-scene.js";
|
|
39
28
|
import { LLMS_TXT } from "../generated/llms-txt.js";
|
|
40
|
-
import { LATEST_SCENEVIEW_RELEASE } from "../generated/version.js";
|
|
29
|
+
import { IOS_NODE_TYPE_COUNT, LATEST_SCENEVIEW_RELEASE } from "../generated/version.js";
|
|
30
|
+
import { AR_SETUP_GUIDE, BEST_PRACTICES, PLATFORM_ROADMAP, TROUBLESHOOTING_GUIDE, } from "../guides.js";
|
|
31
|
+
import { formatMigrationResult, migrateCode } from "../migrate-code.js";
|
|
32
|
+
import { MIGRATION_GUIDE } from "../migration.js";
|
|
33
|
+
import { findNodeSection, listNodeTypes, parseNodeSections } from "../node-reference.js";
|
|
34
|
+
import { getPlatformSetup } from "../platform-setup.js";
|
|
35
|
+
import { buildPreviewUrl, formatPreviewResponse, validatePreviewInput } from "../preview.js";
|
|
36
|
+
import { getSample, SAMPLES } from "../samples.js";
|
|
37
|
+
import { formatSearchResults, searchModels } from "../search-models.js";
|
|
38
|
+
import { formatValidationReport, validateCode } from "../validator.js";
|
|
39
|
+
import { WIDGET_3D_VIEWER_URI } from "../widgets.js";
|
|
41
40
|
// ─── Legal disclaimer (identical to index.ts 4.0.0) ─────────────────────
|
|
42
41
|
const DISCLAIMER = "\n\n---\n*Generated code suggestion. Review before use in production. See [TERMS.md](https://github.com/sceneview/sceneview/blob/main/mcp/TERMS.md).*";
|
|
43
42
|
// ─── Sponsor CTA (shown every N tool calls, opt-out via env var) ────────────
|
|
44
43
|
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
44
|
+
// One line, every `SPONSOR_CTA_INTERVAL` tool calls, pointing at the donation
|
|
45
|
+
// page. Disabled by setting `SCENEVIEW_SPONSOR_CTA=0`. The counter is
|
|
46
|
+
// module-scoped (per MCP process lifetime), not persisted.
|
|
47
|
+
//
|
|
48
|
+
// One link only: an assistant's answer is a bad place for a menu, and Open
|
|
49
|
+
// Collective is the channel that actually receives donations. GitHub Sponsors
|
|
50
|
+
// stays listed in the README and on the site.
|
|
49
51
|
const SPONSOR_CTA_INTERVAL = 10;
|
|
50
|
-
const SPONSOR_CTA = "\n\n💙 *Building SceneView is a one-dev labor of love. If it saved you time, consider [supporting on
|
|
52
|
+
const SPONSOR_CTA = "\n\n💙 *Building SceneView is a one-dev labor of love. If it saved you time, consider [supporting it on Open Collective](https://opencollective.com/sceneview).*";
|
|
51
53
|
let toolCallCount = 0;
|
|
52
54
|
/** Test-only: reset the module-scoped counter between test cases. */
|
|
53
55
|
export function __resetSponsorCounter() {
|
|
@@ -64,10 +66,7 @@ function withDisclaimer(content) {
|
|
|
64
66
|
return content;
|
|
65
67
|
const last = content[content.length - 1];
|
|
66
68
|
const suffix = DISCLAIMER + (shouldShowSponsorCta() ? SPONSOR_CTA : "");
|
|
67
|
-
return [
|
|
68
|
-
...content.slice(0, -1),
|
|
69
|
-
{ ...last, text: last.text + suffix },
|
|
70
|
-
];
|
|
69
|
+
return [...content.slice(0, -1), { ...last, text: last.text + suffix }];
|
|
71
70
|
}
|
|
72
71
|
// ─── llms.txt-derived state ──────────────────────────────────────────────────
|
|
73
72
|
/** Raw API docs markdown — exported for the `sceneview://api` resource. */
|
|
@@ -78,18 +77,15 @@ const NODE_SECTIONS = parseNodeSections(API_DOCS);
|
|
|
78
77
|
/**
|
|
79
78
|
* Run a SceneView MCP tool and return its MCP-formatted result.
|
|
80
79
|
*
|
|
81
|
-
* The caller is responsible for
|
|
82
|
-
*
|
|
83
|
-
* does the same before reaching this function),
|
|
84
|
-
* - rate limiting,
|
|
85
|
-
* - recording billing usage.
|
|
80
|
+
* The caller is responsible for surface filtering (the remote transport
|
|
81
|
+
* refuses the local-only tools of `surfaces.ts`) and rate limiting.
|
|
86
82
|
*
|
|
87
|
-
* This function performs NO auth
|
|
83
|
+
* This function performs NO auth — it is pure business logic.
|
|
88
84
|
*
|
|
89
85
|
* @param toolName MCP tool name, e.g. `"get_sample"`.
|
|
90
86
|
* @param args Arguments bag from the MCP client. `undefined` and
|
|
91
87
|
* `null` are both tolerated.
|
|
92
|
-
* @param _ctx Optional context (user,
|
|
88
|
+
* @param _ctx Optional context (user, request id). Currently
|
|
93
89
|
* unused by any handler, reserved for future tool wiring.
|
|
94
90
|
*/
|
|
95
91
|
export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
@@ -277,11 +273,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
277
273
|
content: withDisclaimer([
|
|
278
274
|
{
|
|
279
275
|
type: "text",
|
|
280
|
-
text: [
|
|
281
|
-
`## \`${section.name}\` — API Reference`,
|
|
282
|
-
``,
|
|
283
|
-
section.content,
|
|
284
|
-
].join("\n"),
|
|
276
|
+
text: [`## \`${section.name}\` — API Reference`, ``, section.content].join("\n"),
|
|
285
277
|
},
|
|
286
278
|
]),
|
|
287
279
|
};
|
|
@@ -408,7 +400,7 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
408
400
|
``,
|
|
409
401
|
`### 2. Minimum Platform`,
|
|
410
402
|
``,
|
|
411
|
-
`AR requires **iOS
|
|
403
|
+
`AR requires **iOS 18.0+** (ARKit + RealityKit). macOS and visionOS use different AR APIs.`,
|
|
412
404
|
``,
|
|
413
405
|
`### 3. Info.plist — Camera Permission`,
|
|
414
406
|
``,
|
|
@@ -502,18 +494,20 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
502
494
|
`### 1. Install`,
|
|
503
495
|
``,
|
|
504
496
|
`\`\`\`bash`,
|
|
505
|
-
`npm install
|
|
497
|
+
`npm install sceneview-web`,
|
|
506
498
|
`\`\`\``,
|
|
507
499
|
``,
|
|
508
|
-
`
|
|
500
|
+
`The npm package is the prebuilt browser bundle (global \`sceneview\` namespace).`,
|
|
501
|
+
`For the Kotlin API (\`io.github.sceneview.web.SceneView\`), depend on the module`,
|
|
502
|
+
`itself from a Kotlin/JS Gradle build — \`sceneview-web\` ships on npm only and has`,
|
|
503
|
+
`no Maven coordinate, so it cannot be resolved as a Gradle module dependency:`,
|
|
509
504
|
`\`\`\`kotlin`,
|
|
510
505
|
`// build.gradle.kts`,
|
|
511
506
|
`kotlin {`,
|
|
512
507
|
` js(IR) { browser(); binaries.executable() }`,
|
|
513
508
|
` sourceSets {`,
|
|
514
509
|
` jsMain.dependencies {`,
|
|
515
|
-
` implementation("
|
|
516
|
-
` // or: implementation(project(":sceneview-web"))`,
|
|
510
|
+
` implementation(project(":sceneview-web"))`,
|
|
517
511
|
` }`,
|
|
518
512
|
` }`,
|
|
519
513
|
`}`,
|
|
@@ -595,7 +589,10 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
595
589
|
}
|
|
596
590
|
const result = buildPreviewUrl({ modelUrl, codeSnippet, autoRotate, ar, title });
|
|
597
591
|
const text = formatPreviewResponse(result);
|
|
598
|
-
return {
|
|
592
|
+
return {
|
|
593
|
+
content: withDisclaimer([{ type: "text", text }]),
|
|
594
|
+
structuredContent: { ...result },
|
|
595
|
+
};
|
|
599
596
|
}
|
|
600
597
|
// ── create_3d_artifact ───────────────────────────────────────────────────
|
|
601
598
|
case "create_3d_artifact": {
|
|
@@ -617,7 +614,10 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
617
614
|
}
|
|
618
615
|
const result = generateArtifact(artifactInput);
|
|
619
616
|
const text = formatArtifactResponse(result);
|
|
620
|
-
return {
|
|
617
|
+
return {
|
|
618
|
+
content: withDisclaimer([{ type: "text", text }]),
|
|
619
|
+
structuredContent: { ...result },
|
|
620
|
+
};
|
|
621
621
|
}
|
|
622
622
|
// ── get_platform_setup ─────────────────────────────────────────────────
|
|
623
623
|
case "get_platform_setup": {
|
|
@@ -654,10 +654,12 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
654
654
|
}
|
|
655
655
|
if (!category) {
|
|
656
656
|
return {
|
|
657
|
-
content: [
|
|
657
|
+
content: [
|
|
658
|
+
{
|
|
658
659
|
type: "text",
|
|
659
660
|
text: `Please provide a \`category\` or \`description\`.\n\nAvailable categories: ${DEBUG_CATEGORIES.join(", ")}`,
|
|
660
|
-
}
|
|
661
|
+
},
|
|
662
|
+
],
|
|
661
663
|
isError: true,
|
|
662
664
|
};
|
|
663
665
|
}
|
|
@@ -689,24 +691,103 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
689
691
|
// users following list_platforms output saw the unresolved template
|
|
690
692
|
// text. Backticks throughout = real interpolation. See #941 follow-up.
|
|
691
693
|
const platforms = [
|
|
692
|
-
{
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
694
|
+
{
|
|
695
|
+
platform: "Android",
|
|
696
|
+
renderer: "Filament",
|
|
697
|
+
framework: "Jetpack Compose",
|
|
698
|
+
status: "Stable",
|
|
699
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
700
|
+
dependency: `io.github.sceneview:sceneview:${LATEST_SCENEVIEW_RELEASE}`,
|
|
701
|
+
features: [
|
|
702
|
+
"3D",
|
|
703
|
+
"AR (ARCore)",
|
|
704
|
+
"Model loading (GLB/glTF)",
|
|
705
|
+
"Geometry nodes",
|
|
706
|
+
"Physics",
|
|
707
|
+
"Gestures",
|
|
708
|
+
],
|
|
709
|
+
},
|
|
710
|
+
{
|
|
711
|
+
platform: "Android TV",
|
|
712
|
+
renderer: "Filament",
|
|
713
|
+
framework: "Compose TV",
|
|
714
|
+
status: "Alpha",
|
|
715
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
716
|
+
dependency: `io.github.sceneview:sceneview:${LATEST_SCENEVIEW_RELEASE}`,
|
|
717
|
+
features: ["3D", "D-pad controls", "Auto-rotation", "Model loading"],
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
platform: "Android XR",
|
|
721
|
+
renderer: "Jetpack XR SceneCore",
|
|
722
|
+
framework: "Compose XR",
|
|
723
|
+
status: "Planned",
|
|
724
|
+
version: "-",
|
|
725
|
+
dependency: "-",
|
|
726
|
+
features: ["Spatial computing", "Hand tracking", "Passthrough"],
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
platform: "iOS",
|
|
730
|
+
renderer: "RealityKit",
|
|
731
|
+
framework: "SwiftUI",
|
|
732
|
+
status: "Alpha",
|
|
733
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
734
|
+
dependency: "SceneViewSwift (SPM)",
|
|
735
|
+
features: ["3D", "AR (ARKit)", `${IOS_NODE_TYPE_COUNT} node types`, "USDZ models"],
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
platform: "macOS",
|
|
739
|
+
renderer: "RealityKit",
|
|
740
|
+
framework: "SwiftUI",
|
|
741
|
+
status: "Alpha",
|
|
742
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
743
|
+
dependency: "SceneViewSwift (SPM)",
|
|
744
|
+
features: ["3D", "Orbit camera", "USDZ models"],
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
platform: "visionOS",
|
|
748
|
+
renderer: "RealityKit",
|
|
749
|
+
framework: "SwiftUI",
|
|
750
|
+
status: "Alpha",
|
|
751
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
752
|
+
dependency: "SceneViewSwift (SPM)",
|
|
753
|
+
features: ["3D", "Immersive spaces", "Hand tracking (planned)"],
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
platform: "Web",
|
|
757
|
+
renderer: "Filament.js (WASM)",
|
|
758
|
+
framework: "Kotlin/JS",
|
|
759
|
+
status: "Alpha",
|
|
760
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
761
|
+
dependency: "sceneview-web (npm)",
|
|
762
|
+
features: ["3D", "WebXR AR/VR", "GLB models", "WebGL2"],
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
platform: "Desktop",
|
|
766
|
+
renderer: "Software / Filament JNI",
|
|
767
|
+
framework: "Compose Desktop",
|
|
768
|
+
status: "Alpha",
|
|
769
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
770
|
+
dependency: "sceneview-desktop (local)",
|
|
771
|
+
features: ["3D", "Software renderer", "Wireframe"],
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
platform: "Flutter",
|
|
775
|
+
renderer: "Filament / RealityKit",
|
|
776
|
+
framework: "PlatformView",
|
|
777
|
+
status: "Alpha",
|
|
778
|
+
version: LATEST_SCENEVIEW_RELEASE,
|
|
779
|
+
dependency: "flutter pub: flutter_sceneview (git ref until first publish, #2735)",
|
|
780
|
+
features: ["3D", "AR", "Android + iOS bridge"],
|
|
781
|
+
},
|
|
701
782
|
];
|
|
702
783
|
const lines = [
|
|
703
784
|
"## SceneView Supported Platforms\n",
|
|
704
785
|
"| Platform | Renderer | Framework | Status | Version |",
|
|
705
786
|
"|----------|----------|-----------|--------|---------|",
|
|
706
|
-
...platforms.map(p => `| ${p.platform} | ${p.renderer} | ${p.framework} | ${p.status} | ${p.version} |`),
|
|
787
|
+
...platforms.map((p) => `| ${p.platform} | ${p.renderer} | ${p.framework} | ${p.status} | ${p.version} |`),
|
|
707
788
|
"",
|
|
708
789
|
"### Platform Details\n",
|
|
709
|
-
...platforms.map(p => [
|
|
790
|
+
...platforms.map((p) => [
|
|
710
791
|
`**${p.platform}** (${p.status})`,
|
|
711
792
|
`- Renderer: ${p.renderer}`,
|
|
712
793
|
`- Framework: ${p.framework}`,
|
|
@@ -719,7 +800,10 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
719
800
|
"SceneView uses **native renderers per platform**: Filament on Android/Web/Desktop, RealityKit on Apple (iOS/macOS/visionOS).",
|
|
720
801
|
"KMP `sceneview-core` shares logic (math, collision, geometry, animations) across all platforms.",
|
|
721
802
|
];
|
|
722
|
-
return {
|
|
803
|
+
return {
|
|
804
|
+
content: withDisclaimer([{ type: "text", text: lines.join("\n") }]),
|
|
805
|
+
structuredContent: { platforms },
|
|
806
|
+
};
|
|
723
807
|
}
|
|
724
808
|
// ── get_animation_guide ─────────────────────────────────────────────────
|
|
725
809
|
case "get_animation_guide": {
|
|
@@ -754,7 +838,12 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
754
838
|
const query = args?.query;
|
|
755
839
|
if (!query || typeof query !== "string" || query.trim().length === 0) {
|
|
756
840
|
return {
|
|
757
|
-
content: [
|
|
841
|
+
content: [
|
|
842
|
+
{
|
|
843
|
+
type: "text",
|
|
844
|
+
text: "Missing required parameter: `query` must be a non-empty string.",
|
|
845
|
+
},
|
|
846
|
+
],
|
|
758
847
|
isError: true,
|
|
759
848
|
};
|
|
760
849
|
}
|
|
@@ -809,7 +898,12 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
809
898
|
const query = args?.query;
|
|
810
899
|
if (!query || typeof query !== "string" || query.trim().length === 0) {
|
|
811
900
|
return {
|
|
812
|
-
content: [
|
|
901
|
+
content: [
|
|
902
|
+
{
|
|
903
|
+
type: "text",
|
|
904
|
+
text: "Missing required parameter: `query` must be a non-empty string.",
|
|
905
|
+
},
|
|
906
|
+
],
|
|
813
907
|
isError: true,
|
|
814
908
|
};
|
|
815
909
|
}
|
|
@@ -825,7 +919,12 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
825
919
|
const uri = args?.uri;
|
|
826
920
|
if (!uri || typeof uri !== "string" || uri.trim().length === 0) {
|
|
827
921
|
return {
|
|
828
|
-
content: [
|
|
922
|
+
content: [
|
|
923
|
+
{
|
|
924
|
+
type: "text",
|
|
925
|
+
text: "Missing required parameter: `uri` must be a non-empty `kb://...` string.",
|
|
926
|
+
},
|
|
927
|
+
],
|
|
829
928
|
isError: true,
|
|
830
929
|
};
|
|
831
930
|
}
|
|
@@ -836,6 +935,48 @@ export async function dispatchTool(toolName, args, _ctx = {}) {
|
|
|
836
935
|
isError: docResult.ok ? undefined : true,
|
|
837
936
|
};
|
|
838
937
|
}
|
|
938
|
+
// ── view_3d_model (MCP Apps widget) ──────────────────────────────────────
|
|
939
|
+
//
|
|
940
|
+
// Returns nothing the model must reason about beyond a one-line summary:
|
|
941
|
+
// the payload lives in `structuredContent`, which the host hands to the
|
|
942
|
+
// `ui://widget/3d-viewer.html` resource (see `../widgets.ts`). No
|
|
943
|
+
// disclaimer here — nothing is generated, the viewer just loads a URL.
|
|
944
|
+
case "view_3d_model": {
|
|
945
|
+
const modelUrl = typeof args?.modelUrl === "string" ? args.modelUrl.trim() : "";
|
|
946
|
+
if (!modelUrl) {
|
|
947
|
+
return {
|
|
948
|
+
content: [
|
|
949
|
+
{
|
|
950
|
+
type: "text",
|
|
951
|
+
text: "view_3d_model requires a `modelUrl` argument (a public HTTPS URL to a .glb, .gltf or .3mf file).",
|
|
952
|
+
},
|
|
953
|
+
],
|
|
954
|
+
isError: true,
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
const title = typeof args?.title === "string" && args.title.trim() ? args.title.trim() : "3D model";
|
|
958
|
+
const autoRotate = args?.autoRotate !== false;
|
|
959
|
+
const ar = args?.ar !== false;
|
|
960
|
+
const alt = typeof args?.alt === "string" && args.alt.trim() ? args.alt.trim() : title;
|
|
961
|
+
const posterUrl = typeof args?.posterUrl === "string" && args.posterUrl ? args.posterUrl : undefined;
|
|
962
|
+
// The text block is for clients that do not render the widget: it
|
|
963
|
+
// gives the assistant something to say about what was shown.
|
|
964
|
+
const summary = `Loading 3D viewer for ${title} (${modelUrl}).${ar ? " AR mode is available on supported mobile devices." : ""}`;
|
|
965
|
+
return {
|
|
966
|
+
content: [{ type: "text", text: summary }],
|
|
967
|
+
// `posterUrl` is omitted rather than `undefined`: the outputSchema has
|
|
968
|
+
// `additionalProperties: false` and hosts validate against it.
|
|
969
|
+
structuredContent: {
|
|
970
|
+
modelUrl,
|
|
971
|
+
title,
|
|
972
|
+
autoRotate,
|
|
973
|
+
ar,
|
|
974
|
+
alt,
|
|
975
|
+
...(posterUrl === undefined ? {} : { posterUrl }),
|
|
976
|
+
},
|
|
977
|
+
_meta: { ui: { resourceUri: WIDGET_3D_VIEWER_URI } },
|
|
978
|
+
};
|
|
979
|
+
}
|
|
839
980
|
default:
|
|
840
981
|
return {
|
|
841
982
|
content: [{ type: "text", text: `Unknown tool: ${toolName}` }],
|
package/dist/tools/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public entrypoint for the SceneView MCP tool library.
|
|
3
3
|
*
|
|
4
|
-
* Consumers (stdio server in `../index.ts`,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Consumers (stdio server in `../index.ts`, HTTP server in `../server.ts`)
|
|
5
|
+
* should import from this file and never reach into `definitions.ts` /
|
|
6
|
+
* `handler.ts` directly.
|
|
7
7
|
*/
|
|
8
8
|
export { TOOL_DEFINITIONS } from "./definitions.js";
|
|
9
|
-
export {
|
|
9
|
+
export { __resetSponsorCounter, API_DOCS, dispatchTool } from "./handler.js";
|
|
10
10
|
import { TOOL_DEFINITIONS } from "./definitions.js";
|
|
11
11
|
/** Returns the full tool definition list (read-only copy). */
|
|
12
12
|
export function getAllTools() {
|
package/dist/tools/types.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public types for the SceneView MCP tool library.
|
|
3
|
-
*
|
|
4
|
-
* These are the contract shared with the `mcp-gateway` package. Any change here
|
|
5
|
-
* MUST be reflected in `mcp-gateway/src/mcp/types.ts` (or that file should
|
|
6
|
-
* import from this one once workspaces are set up).
|
|
7
3
|
*/
|
|
8
4
|
export {};
|