Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Ship prebuilt MCP authoring tools in 67js 0.5.0

Nguyen Xuan An5684791f299d
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index e19209e3..96fcc2ae 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -29,5 +29,6 @@ jobs:
- run: npm test
- run: npm run prepare:release
- run: npm run smoke:package
+ - run: npm run smoke:mcp-package -- --protocol-only
- name: Publish a new version through OIDC
run: npm run publish:ci
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5aa84c21..979e5236 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,10 +1,13 @@
# Changelog
-## Unreleased
+## 0.5.0
- Add atomic agent commands for creating, removing and rebinding nodes and shared resources, with bounded checkpoint geometry ownership.
- Reconcile rigid untextured renderer topology while retaining unchanged batches and sharing immutable geometry buffers across draws.
-- Add source-checkout MCP tools with strict scene schemas, persistent CPU/GPU previews and bounded PNG responses.
+- Ship the `67js-mcp` npm command with a prebuilt SDK server, browser preview and complete bundled dependency licenses.
+- Add twelve MCP tools with strict scene schemas, persistent CPU/GPU previews and bounded PNG responses.
+- Import local catalog GLBs with supported material maps, rigs, morphs and deterministic clip sampling.
+- Retain authored lighting, volumetric fog, grading and directional shadow coverage across edits and checkpoints.
- Keep renderer sessions alive across edits and close owned browser resources when the MCP connection ends.
- Add optional agent scene sessions with stable IDs, shared geometry, revision checks, atomic edits and bounded checkpoints.
- Prioritize agent authoring, visual feedback and MCP integration in the implementation roadmap.
diff --git a/README.md b/README.md
index 6c9cee42..5a1c289b 100644
--- a/README.md
+++ b/README.md
@@ -124,15 +124,17 @@ The repository includes two reusable Codex skills.
## Agent authoring
-The current source includes [agent scene sessions](docs/agent-scene.md), newer than npm `0.4.1`.
+Version `0.5.0` includes [agent scene sessions](docs/agent-scene.md) and the `67js-mcp` command.
Agents can author JSON recipes, inspect object bounds, submit atomic edits and restore bounded checkpoints.
Agents can add or remove nodes and shared resources in the same revisioned command stream.
The optional addon retains unchanged parts and geometry across supported edits.
-The source [MCP server](docs/mcp.md) connects these sessions to a persistent browser renderer.
+The packaged [MCP server](docs/mcp.md) connects these sessions to a persistent browser renderer.
Agents receive PNG previews and structured scene metadata through twelve stdio tools.
Agents can author [lights, volumetric fog, grading and shadow coverage](docs/agent-look.md), then restore the complete look from a checkpoint.
-Run `node scripts/mcp-server.mjs --backend gpu --memory 192` from a checkout with project dependencies and a local Chrome installation.
+After installing the package, run `npx 67js-mcp --backend gpu --memory 192` with Node.js 20.19 or later and a local Chrome installation.
+The server and preview are built into the package. The browser driver loads only when a scene is created.
+
The [asset adapter](docs/agent-asset.md) imports catalog GLBs with supported textures, rigs, morphs and clips.
Animation track authoring, imported mesh topology edits and persistent video jobs remain implementation work.
diff --git a/ROADMAP.md b/ROADMAP.md
index 8163ec12..2020eb53 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -20,13 +20,15 @@ This document separates shipping capabilities from work in progress. Performance
- Optional recorded Rapier physics with contacts, joint limits and bounded motors.
- Static sculpt brushes, clipped surface patches, shrinkwrap and bounded mesh contact and containment queries.
-## Next
-
-The current source, after npm `0.4.1`, includes agent scenes with stable IDs, atomic resource/node edits and checkpoints.
+Version `0.5.0` includes agent scenes with stable IDs, atomic resource/node edits and checkpoints.
Its stdio MCP server supplies twelve schema-backed tools and persistent CPU/GPU image previews.
Recipes retain lighting, volumetric fog, grading and directional shadow coverage with atomic edits and undo.
Imported asset sessions retain supported textures, rigs, morphs and clips from a configured local GLB catalog.
+The npm package includes the prebuilt `67js-mcp` command with lazy browser startup and bundled dependency licenses.
+
+## Next
+
1. Extend imported asset sessions with node-level editing, topology changes and deformed geometry diagnostics.
2. Extend MCP visual feedback with bounded multi-angle and absolute animation-time previews.
3. Persistent render jobs with progress, cancellation, explicit CPU/GPU budgets and deterministic image and video export.
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 90b9f306..2ce09fa8 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -76,6 +76,15 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+## MCP command and browser preview
+
+The packaged `build/mcp/server.mjs` and `build/mcp/preview.js` bundle the MCP SDK,
+schema validation and rendering dependencies. `build/mcp/LICENSES.md` contains
+their complete license and notice texts, including dependencies embedded in the SDK.
+`build/mcp/manifest.json` records dependency versions, license provenance and output SHA-256 hashes.
+Pinned upstream license copies for embedded dependencies are retained in `licenses/mcp/` in the source repository.
+The external `playwright-core` browser driver includes its own license and notices in its dependency package.
+
## Simple Icons (package-manager logos)
The npm, pnpm, Yarn and Bun SVG marks are sourced from Simple Icons and distributed under CC0-1.0. See public/licenses/simple-icons.txt. Brand marks remain subject to their respective trademark rights.
diff --git a/bin/67js-mcp.mjs b/bin/67js-mcp.mjs
new file mode 100644
index 00000000..09eb5cd0
--- /dev/null
+++ b/bin/67js-mcp.mjs
@@ -0,0 +1,27 @@
+#!/usr/bin/env node
+import { constants, setPriority } from 'node:os';
+import packageMetadata from '../package.json' with { type: 'json' };
+
+const argumentsValue = process.argv.slice(2);
+if (argumentsValue.length === 1 && argumentsValue[0] === '--version') {
+ console.log(packageMetadata.version);
+} else if (argumentsValue.length === 1 && argumentsValue[0] === '--help') {
+ console.log(`67js-mcp ${packageMetadata.version}
+Usage: 67js-mcp [--backend gpu|cpu] [--memory 32..256]
+ [--browser <Chrome/Chromium executable>] [--assets <absolute GLB directory>]
+
+Connect an MCP client over stdin/stdout. Chrome starts on the first scene.
+Uses installed Chrome by default; supply --browser for another Chromium executable.
+Documentation: https://67js.codepawl.com/mcp.md`);
+} else {
+ try {
+ setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
+ const { runMcpCli } = await import('../build/mcp/server.mjs');
+ await runMcpCli({ argumentsValue, version: packageMetadata.version,
+ previewUrl: new URL('../build/mcp/preview.js', import.meta.url),
+ });
+ } catch (error) {
+ console.error(error.message);
+ process.exitCode = 1;
+ }
+}
diff --git a/docs/agent-asset.md b/docs/agent-asset.md
index f2cbe8bf..3d2e89a0 100644
--- a/docs/agent-asset.md
+++ b/docs/agent-asset.md
@@ -1,13 +1,13 @@
# Imported asset authoring
-`src/agent-asset.js` is an optional source module added after 0.4.1. It wraps one
+`67js/addons/agent-asset` is an optional addon available since 0.5.0. It wraps one
decoded `parseGltf()` asset in a JSON authoring session. It preserves renderer
geometry, texture descriptors, skins, morph targets, and their typed arrays.
The module performs CPU validation and creates no GPU resources.
```js
-import { parseGltf } from './src/gltf.js';
-import { createAgentAssetScene } from './src/agent-asset.js';
+import { parseGltf } from '67js/addons/gltf';
+import { createAgentAssetScene } from '67js/addons/agent-asset';
const asset = await parseGltf(glbBytes);
const scene = createAgentAssetScene(asset, {
diff --git a/docs/agent-look.md b/docs/agent-look.md
index e1e2c5e2..63942de0 100644
--- a/docs/agent-look.md
+++ b/docs/agent-look.md
@@ -1,14 +1,13 @@
# Agent lighting and look
-This feature is available in the current source checkout, after npm release `0.4.1`.
-It is not included in the published `0.4.1` package.
+This feature is included in npm release `0.5.0` and later.
Agent scene recipes can contain `environment`, `effects`, and `shadow` objects.
These fields belong to canonical recipes and checkpoint snapshots.
Look commands use the same atomic revision checks as node and material commands.
Failed look validation preserves the previous recipe and revision.
-The source helper `normalizeAgentLook({ environment, effects, shadow })` returns detached, fully normalized JSON.
+The optional helper `normalizeAgentLook({ environment, effects, shadow })` returns detached, fully normalized JSON.
It fills omitted fields without mutating the input.
`resolveAgentShadow(shadow, lightDirection)` returns detached renderer bounds with `eye`, `target`, `up`, `extent`, `near`, and `far`.
The helpers do not create geometry, render targets, or GPU resources.
diff --git a/docs/agent-scene.md b/docs/agent-scene.md
index 70717345..87e90abc 100644
--- a/docs/agent-scene.md
+++ b/docs/agent-scene.md
@@ -1,7 +1,6 @@
# Agent scene authoring
-This addon is available in the current source checkout, after npm release `0.4.1`.
-It is not included in the published `0.4.1` package.
+This addon is included in npm release `0.5.0` and later.
The optional `agent-scene` addon creates bounded CPU scenes from JSON recipes and applies atomic editing commands.
It returns retained renderer parts with shared geometry and material resources.
diff --git a/docs/guide.md b/docs/guide.md
index 943c33dc..773edab4 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -400,9 +400,9 @@ Disconnect observers, cancel animation frames, release pointer state and call `d
## Models and AI agents
-The current source includes [agent scene sessions](/agent-scene.md), newer than npm `0.4.1`.
+Version `0.5.0` includes [agent scene sessions](/agent-scene.md) and the `67js-mcp` command.
Its [MCP server](/mcp.md) provides twelve tools for creating, inspecting, editing and previewing scenes through a persistent browser renderer.
-Read the matching checkout's MCP guide for launch configuration, CPU/GPU selection and source-only availability.
+Read the MCP guide for npm installation, client configuration and CPU/GPU selection.
The [agent look contract](/agent-look.md) adds retained lighting, volumetric fog, grading and directional shadows to recipe edits and checkpoints.
The [asset adapter](/agent-asset.md) imports local catalog GLBs with supported textures, rigs, morphs and deterministic clip sampling.
diff --git a/docs/mcp.md b/docs/mcp.md
index 96e86c16..09c0b4ef 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -1,7 +1,6 @@
# MCP scene authoring
-The stdio server is available in the source checkout after npm release `0.4.1`.
-The published `0.4.1` package does not include this server.
+The `67js-mcp` stdio server is included in npm release `0.5.0` and later.
It uses the maintained MCP TypeScript SDK v2 server and a local browser runtime.
The [official SDK documentation](https://ts.sdk.modelcontextprotocol.io/v2/) describes its transport and protocol APIs.
@@ -12,18 +11,24 @@ The image bytes appear only in the image content block.
## Requirements and launch
-The server requires Node.js 20 or later, installed project dependencies, and a local Chrome or Chromium executable.
-The browser and its build dependencies load when `scene_create` or `scene_create_asset` runs.
-The runtime serves its generated scene page on the loopback interface.
+The server requires Node.js 20.19 or later and an installed Chrome or Chromium executable.
+The npm package contains a prebuilt server and browser preview. A source checkout and Vite are unnecessary.
+The browser driver loads when `scene_create` or `scene_create_asset` runs. It does not download a browser.
+
+The runtime serves its bundled scene page on the loopback interface.
The MCP connection uses stdin and stdout, without an HTTP MCP listener.
-1. Run the server from the source checkout:
+1. Install the package in your project:
```powershell
- node scripts/mcp-server.mjs --backend gpu --memory 192
+ npm install 67js@npm:@codepawlhq/67js
```
-2. Configure your MCP client with absolute paths:
+ Run the installed command with `npx 67js-mcp --backend gpu --memory 192`.
+ For a standalone launch, use `npx --package @codepawlhq/[email protected] 67js-mcp --backend gpu --memory 192`.
+ `67js-mcp --help` lists options. `67js-mcp --version` reports the installed version.
+
+2. Configure your MCP client with absolute paths to Node and the installed CLI:
```json
{
@@ -31,7 +36,7 @@ The MCP connection uses stdin and stdout, without an HTTP MCP listener.
"67js-scene": {
"command": "C:/Program Files/nodejs/node.exe",
"args": [
- "C:/projects/67js/scripts/mcp-server.mjs",
+ "C:/projects/my-scene/node_modules/67js/bin/67js-mcp.mjs",
"--backend", "gpu",
"--memory", "192",
"--browser", "C:/Program Files/Google/Chrome/Application/chrome.exe"
@@ -41,7 +46,8 @@ The MCP connection uses stdin and stdout, without an HTTP MCP listener.
}
```
-The browser path is optional when the runtime can locate a supported browser.
+The browser path is optional for a standard Google Chrome installation. Pass `--browser` for another Chromium executable.
+Using Node directly also avoids shell-specific npm launcher behavior in MCP clients on Windows.
`--backend` accepts `gpu` or `cpu` and defaults to `gpu`.
`--memory` accepts an integer from 32 to 256 MiB and defaults to 192.
diff --git a/docs/release-verification.md b/docs/release-verification.md
index 25f3618f..107cb126 100644
--- a/docs/release-verification.md
+++ b/docs/release-verification.md
@@ -1,5 +1,25 @@
# Release verification
+## 0.5.0
+
+Source checks used Windows Node.js and installed Chrome with CPU SwiftShader.
+Registry publication and live deployment are verified separately against the pushed commit.
+
+| Check | Measured result |
+| --- | --- |
+| Node tests | 373 tests passed. |
+| Installed CLI | A fresh project installed the archive with development dependencies omitted and scripts disabled. The npm launcher, help and version worked. |
+| Protocol | Modern and legacy SDK clients discovered twelve tools and received the package version. Capabilities did not start a browser. |
+| Actual rendering | Imported fixtures retained one material texture and one skin. Lighting edits changed PNG output, and undo restored the original PNG exactly. |
+| Animation | Sampling an imported clip backward and forward reproduced the same PNG while retaining geometry buffers. |
+| Cleanup | Closing the MCP connection with an active scene closed owned preview resources and exited the server process. |
+| Consumer | The packed core and addons imported correctly, including an actual physics contact simulation. |
+| Licenses | The MCP build reported no missing dependency licenses and recorded output hashes in its manifest. |
+| Website | Homepage and agent docs rendered without horizontal overflow or page errors at 1440 and 390 pixels. |
+
+These checks establish CPU preview behavior. They do not establish hardware GPU performance or cinematic quality.
+MCP animation track authoring, imported topology changes and persistent video jobs remain unsupported.
+
## 0.4.0
The source validation used Windows Chrome, ANGLE D3D11 and an RTX 3060.
diff --git a/index.html b/index.html
index b0d89dbb..b30c7b19 100644
--- a/index.html
+++ b/index.html
@@ -4,8 +4,8 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#191d22" />
- <meta name="description" content="67.js is a browser graphics engine for interactive scenes and cinematic media. Explore demos, install a release and start building." />
- <title>67.js · JavaScript graphics engine</title>
+ <meta name="description" content="3D tools for agents: author scenes, import models, inspect PNG previews and refine with atomic edits and undo. Install 67.js for browser rendering and MCP." />
+ <title>67.js · 3D tools for agents</title>
<link rel="icon" href="/favicon.svg" />
</head>
<body>
@@ -19,7 +19,7 @@
</header>
<main id="content">
<section class="hero" aria-label="67.js introduction and live preview">
- <header class="introduction"><div><h1>Your 3D scene,<br />from browser to film</h1><p>Build interactive 3D, animate it and export the same scene as images or video.</p><section id="downloads" class="home-install" aria-label="Install 67.js">
+ <header class="introduction"><div><h1>3D scenes,<br />built with agents</h1><p>Give agents tools to build, inspect and refine 3D. Preview in your browser, then export the scene.</p><section id="downloads" class="home-install" aria-label="Install 67.js">
<div class="package-install">
<div class="package-managers" role="group" aria-label="Package manager">
<button data-package-manager="npm" aria-pressed="true"><span class="package-logo package-logo-npm" aria-hidden="true"></span><span>npm</span></button>
diff --git a/licenses/mcp/ajv-8.18.0.txt b/licenses/mcp/ajv-8.18.0.txt
new file mode 100644
index 00000000..e409b403
--- /dev/null
+++ b/licenses/mcp/ajv-8.18.0.txt
@@ -0,0 +1,27 @@
+Source: https://registry.npmjs.org/ajv/-/ajv-8.18.0.tgz
+Integrity: sha512-PlXPeEWMXMZ7sPYOHqmDyCJzcfNrUr3fGNKtezX14ykXOEIvyK81d+qydx89KY5O71FKMPaQ2vBfBFI5NHR63A==
+
+package/LICENSE
+
+The MIT License (MIT)
+
+Copyright (c) 2015-2021 Evgeny Poberezkin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/licenses/mcp/ajv-formats-3.0.1.txt b/licenses/mcp/ajv-formats-3.0.1.txt
new file mode 100644
index 00000000..78bf907a
--- /dev/null
+++ b/licenses/mcp/ajv-formats-3.0.1.txt
@@ -0,0 +1,27 @@
+Source: https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz
+Integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==
+
+package/LICENSE
+
+MIT License
+
+Copyright (c) 2020 Evgeny Poberezkin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/licenses/mcp/content-type-1.0.5.txt b/licenses/mcp/content-type-1.0.5.txt
new file mode 100644
index 00000000..218310de
--- /dev/null
+++ b/licenses/mcp/content-type-1.0.5.txt
@@ -0,0 +1,28 @@
+Source: https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz
+Integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==
+
+package/LICENSE
+
+(The MIT License)
+
+Copyright (c) 2015 Douglas Christopher Wilson
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/licenses/mcp/fast-deep-equal-3.1.3.txt b/licenses/mcp/fast-deep-equal-3.1.3.txt
new file mode 100644
index 00000000..85f12406
--- /dev/null
+++ b/licenses/mcp/fast-deep-equal-3.1.3.txt
@@ -0,0 +1,27 @@
+Source: https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz
+Integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
+
+package/LICENSE
+
+MIT License
+
+Copyright (c) 2017 Evgeny Poberezkin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/licenses/mcp/fast-uri-3.1.0.txt b/licenses/mcp/fast-uri-3.1.0.txt
new file mode 100644
index 00000000..f8048003
--- /dev/null
+++ b/licenses/mcp/fast-uri-3.1.0.txt
@@ -0,0 +1,38 @@
+Source: https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz
+Integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==
+
+package/LICENSE
+
+Copyright (c) 2011-2021, Gary Court until https://github.com/garycourt/uri-js/commit/a1acf730b4bba3f1097c9f52e7d9d3aba8cdcaae
+Copyright (c) 2021-present The Fastify team
+All rights reserved.
+
+The Fastify team members are listed at https://github.com/fastify/fastify#team.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * The names of any contributors may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ * * *
+
+The complete list of contributors can be found at:
+- https://github.com/garycourt/uri-js/graphs/contributors
diff --git a/licenses/mcp/json-schema-traverse-1.0.0.txt b/licenses/mcp/json-schema-traverse-1.0.0.txt
new file mode 100644
index 00000000..897178e7
--- /dev/null
+++ b/licenses/mcp/json-schema-traverse-1.0.0.txt
@@ -0,0 +1,27 @@
+Source: https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz
+Integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==
+
+package/LICENSE
+
+MIT License
+
+Copyright (c) 2017 Evgeny Poberezkin
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/package-lock.json b/package-lock.json
index f5e8cbb9..d91d341d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,13 +1,19 @@
{
"name": "@codepawlhq/67js",
- "version": "0.4.1",
+ "version": "0.5.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@codepawlhq/67js",
- "version": "0.4.1",
+ "version": "0.5.0",
"license": "MIT",
+ "dependencies": {
+ "playwright-core": "1.64.0"
+ },
+ "bin": {
+ "67js-mcp": "bin/67js-mcp.mjs"
+ },
"devDependencies": {
"@codepawlhq/orglet-ui": "0.2.1",
"@dimforge/rapier3d-compat": "0.21.0",
@@ -24,6 +30,9 @@
"wrangler": "4.149.0",
"zod": "4.6.5"
},
+ "engines": {
+ "node": ">=20.19.0"
+ },
"peerDependencies": {
"@dimforge/rapier3d-compat": "0.21.0"
},
@@ -2573,7 +2582,6 @@
"version": "1.64.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.0.tgz",
"integrity": "sha512-T9r+MZkTECl2+oUcZ26YgZzTrYidTsIhYYkJix+6iDOymOb1FB2RLLSOxRGnZGv5DStt+aduIVbt+E8WygXYpg==",
- "dev": true,
"license": "Apache-2.0",
"bin": {
"playwright-core": "cli.js"
diff --git a/package.json b/package.json
index 00f174bc..6f4196d4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@codepawlhq/67js",
- "version": "0.4.1",
+ "version": "0.5.0",
"private": false,
"type": "module",
"description": "JavaScript tools for agent-driven 3D authoring, browser previews and memory-aware CPU/GPU rendering",
@@ -12,6 +12,7 @@
},
"files": [
"build",
+ "bin",
"README.md",
"LICENSE",
"CHANGELOG.md",
@@ -49,6 +50,12 @@
],
"main": "./build/67.module.js",
"module": "./build/67.module.js",
+ "bin": {
+ "67js-mcp": "./bin/67js-mcp.mjs"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
"exports": {
".": "./build/67.module.js",
"./addons/model": "./build/model.js",
@@ -71,7 +78,7 @@
"scripts": {
"dev": "vite --host 127.0.0.1",
"build": "node scripts/prepare-release.mjs && vite build",
- "build:lib": "vite build --config vite.lib.config.js",
+ "build:lib": "vite build --config vite.lib.config.js && node scripts/build-mcp.mjs",
"prepare:release": "node scripts/prepare-release.mjs",
"prepack": "npm run build:lib",
"deploy": "node scripts/deploy.mjs",
@@ -84,8 +91,9 @@
"score": "node scripts/score.mjs",
"export:model": "node scripts/export-model.mjs",
"smoke:package": "node scripts/smoke-package.mjs",
- "mcp": "node scripts/mcp-server.mjs",
+ "mcp": "node bin/67js-mcp.mjs",
"smoke:mcp": "node scripts/smoke-mcp.mjs",
+ "smoke:mcp-package": "node scripts/smoke-mcp-package.mjs",
"smoke:agent-topology": "node scripts/smoke-agent-topology.mjs",
"smoke:agent-look": "node scripts/smoke-agent-look.mjs",
"smoke:agent-assets": "node scripts/smoke-agent-assets.mjs",
@@ -96,6 +104,9 @@
"peerDependencies": {
"@dimforge/rapier3d-compat": "0.21.0"
},
+ "dependencies": {
+ "playwright-core": "1.64.0"
+ },
"peerDependenciesMeta": {
"@dimforge/rapier3d-compat": {
"optional": true
diff --git a/public/llms.txt b/public/llms.txt
index 6794e16c..b267d4a1 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -7,16 +7,19 @@ The installed package determines available APIs. Release metadata describes the
## Read only what your task needs
-The current source adds `67js/addons/agent-scene`, newer than npm `0.4.1`.
+Version `0.5.0` adds `67js/addons/agent-scene` and the `67js-mcp` command.
Read `/agent-scene.md` for versioned JSON recipes, stable IDs, expected revisions, atomic edits and bounded checkpoints.
Use `session.inspect()` for compact object facts and `session.exportRecipe()` for detached JSON.
Keep renderer-facing geometry immutable. Call `renderer.updateParts(session.parts)` after a successful edit or restore.
This addon does not expose an MCP server or a render job queue.
-The source checkout provides a separate stdio MCP server in `scripts/mcp-server.mjs`, after npm `0.4.1`.
+The npm package includes a prebuilt stdio MCP server. After alias installation, run `npx 67js-mcp --backend gpu --memory 192` with Node.js 20.19+ and installed Chrome.
+For MCP clients, invoke Node directly with the absolute path to `node_modules/67js/bin/67js-mcp.mjs`. Read `/mcp.md` for configuration.
+The browser starts only when creating a scene. No source checkout, Vite build or browser download is required.
+
Read `/mcp.md` before configuring it. Start with `scene_capabilities`, create a recipe and inspect its stable IDs.
-Read `/agent-asset.md` for source-only imported asset sessions and the `67js/addons/agent-asset` addon.
+Read `/agent-asset.md` for imported asset sessions available since `0.5.0` and the `67js/addons/agent-asset` addon.
Configure --assets with an absolute GLB directory, then call scene_asset_catalog and scene_create_asset with a content-bound asset ID.
Imported scenes preserve supported maps, skins, morphs and clips. Their topology remains fixed.
Use set-root for asset placement and set-animation for absolute clip/time sampling. Checkpoint before sampling or relighting.
diff --git a/scripts/agent-asset-fixture.mjs b/scripts/agent-asset-fixture.mjs
new file mode 100644
index 00000000..37710e3d
--- /dev/null
+++ b/scripts/agent-asset-fixture.mjs
@@ -0,0 +1,14 @@
+import { readFile } from 'node:fs/promises';
+import { skinnedStripAsset } from '../tests/fixtures/skinned-strip.js';
+
+/** Embedded PNG on an animated skin, exercising the actual decoder and shader path. */
+export async function createTexturedRigFixture() {
+ const document = JSON.parse(await readFile(new URL('../tests/fixtures/textured-triangle.gltf', import.meta.url), 'utf8'));
+ const image = Buffer.from(document.images[0].uri.split(',')[1], 'base64');
+ return Buffer.from(skinnedStripAsset((asset, append) => {
+ append(new Uint8Array(image), 'SCALAR');
+ asset.images = [{ bufferView: asset.bufferViews.length - 1, mimeType: 'image/png' }];
+ asset.textures = [{ source: 0 }];
+ asset.materials[0].pbrMetallicRoughness.baseColorTexture = { index: 0 };
+ }));
+}
diff --git a/scripts/agent-runtime.mjs b/scripts/agent-runtime.mjs
index 31a7a78c..fe8a388f 100644
--- a/scripts/agent-runtime.mjs
+++ b/scripts/agent-runtime.mjs
@@ -1,8 +1,9 @@
import { createServer } from 'node:http';
import { randomUUID } from 'node:crypto';
import { existsSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
+import { readFile } from 'node:fs/promises';
import { isAbsolute } from 'node:path';
+import packageMetadata from '../package.json' with { type: 'json' };
import { createAgentScene, AGENT_SCENE_CAPABILITIES } from '../src/agent-scene.js';
import { createAgentAssetCatalog } from './agent-asset-catalog.mjs';
@@ -14,7 +15,8 @@ const EVALUATION_TIMEOUT_MS = 30000;
const html = '<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;height:100%;background:#182126}canvas{display:block;width:100vw;height:100vh}</style></head><body><canvas></canvas><script type="module" src="/preview.js"></script></body></html>';
/** Local, serialized browser preview. No browser is launched until scene creation. */
-export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memory = 192, assets: assetRoot } = {}) {
+export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memory = 192, assets: assetRoot,
+ previewUrl = new URL('../build/mcp/preview.js', import.meta.url) } = {}) {
if (!['gpu', 'cpu'].includes(backend)) {
throw new RangeError('backend must be gpu or cpu.');
}
@@ -82,26 +84,10 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
}
phase = 'starting';
try {
- const [{ build }, { chromium }] = await Promise.all([
- import('vite'),
- import('playwright'),
+ const [{ chromium }, code] = await Promise.all([
+ import('playwright-core'),
+ readFile(previewUrl, 'utf8'),
]);
- const root = fileURLToPath(new URL('..', import.meta.url));
- const bundle = await build({
- root,
- configFile: false,
- logLevel: 'silent',
- build: {
- write: false,
- minify: false,
- lib: { entry: fileURLToPath(new URL('./agent-preview-browser.js', import.meta.url)), formats: ['es'] },
- },
- });
- const outputs = (Array.isArray(bundle) ? bundle : [bundle]).flatMap(result => result.output);
- if (outputs.length !== 1 || outputs[0].type !== 'chunk' || !outputs[0].isEntry) {
- throw new Error('The private preview must produce one self-contained module.');
- }
- const code = outputs[0].code;
httpServer = createServer((request, response) => {
response.setHeader('Cache-Control', 'no-store');
response.setHeader('Content-Security-Policy', "default-src 'none'; script-src 'self'; style-src 'unsafe-inline'; img-src data: blob:; connect-src blob:");
@@ -118,13 +104,13 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
httpServer.listen(0, '127.0.0.1', resolve);
});
const origin = `http://127.0.0.1:${httpServer.address().port}`;
- const nativeChrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe';
- const executablePath = browserPath ?? (existsSync(nativeChrome) ? nativeChrome : undefined);
const args = ['--enable-webgl', '--ignore-gpu-blocklist', '--disable-renderer-backgrounding'];
if (backend === 'cpu') {
args.push('--use-angle=swiftshader', '--enable-unsafe-swiftshader');
}
- browserInstance = await chromium.launch({ headless: true, executablePath, args });
+ browserInstance = await chromium.launch({ headless: true, args,
+ ...(browserPath ? { executablePath: browserPath } : { channel: 'chrome' }),
+ });
page = await browserInstance.newPage({ viewport: { width: 768, height: 512 }, deviceScaleFactor: 1 });
await page.route('**/*', route => {
const url = new URL(route.request().url());
@@ -188,7 +174,7 @@ export function createAgentRuntime({ backend = 'gpu', browser: browserPath, memo
sceneLimits: SCENE_LIMITS,
preview: { backend, memoryBudgetMiB: memory, maximumWidth: 1024, maximumHeight: 1024, maximumImageBytes: MAXIMUM_IMAGE_BYTES, maximumActiveScenes: 1, maximumQueuedCalls: MAXIMUM_QUEUED_CALLS, evaluationTimeoutMs: EVALUATION_TIMEOUT_MS },
phase: closing && phase !== 'closed' ? 'closing' : phase,
- availableIn: 'source after npm 0.4.1',
+ availableIn: packageMetadata.version,
assets: {
configured: Boolean(assetRoot), formats: ['self-contained GLB'],
maximumBytes: 16 * 1024 * 1024, maximumAssets: 64,
diff --git a/scripts/build-mcp.mjs b/scripts/build-mcp.mjs
new file mode 100644
index 00000000..ee90de23
--- /dev/null
+++ b/scripts/build-mcp.mjs
@@ -0,0 +1,210 @@
+import { readFile, writeFile, mkdir, readdir } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import { createHash } from 'node:crypto';
+import { spawnSync } from 'node:child_process';
+import { constants, setPriority } from 'node:os';
+import { isBuiltin } from 'node:module';
+import { dirname, resolve, join, relative, isAbsolute } from 'node:path';
+import { fileURLToPath, pathToFileURL } from 'node:url';
+
+const root = fileURLToPath(new URL('..', import.meta.url));
+
+function digest(bytes) {
+ return createHash('sha256').update(bytes).digest('hex');
+}
+
+async function packageAt(directory) {
+ const metadataPath = join(directory, 'package.json');
+ if (!existsSync(metadataPath)) return null;
+ return { directory, metadata: JSON.parse(await readFile(metadataPath, 'utf8')) };
+}
+
+async function dependencyFor(moduleId) {
+ if (!moduleId.includes('node_modules')) return null;
+ let directory = dirname(moduleId.split('?')[0]);
+ while (directory !== dirname(directory)) {
+ const dependency = await packageAt(directory);
+ if (dependency?.metadata.name && dependency.metadata.version) return dependency;
+ directory = dirname(directory);
+ }
+ return null;
+}
+
+async function collectLicenses(chunks) {
+ const dependencies = new Map();
+ const embedded = new Map();
+ const rootsByModule = new Map();
+ for (const chunk of chunks) {
+ for (const [moduleId, information] of Object.entries(chunk.modules)) {
+ if (information.renderedLength === 0) continue;
+ let dependency = rootsByModule.get(moduleId);
+ if (dependency === undefined) {
+ dependency = await dependencyFor(moduleId);
+ rootsByModule.set(moduleId, dependency);
+ }
+ if (!dependency) continue;
+ const key = `${dependency.metadata.name}@${dependency.metadata.version}`;
+ dependencies.set(key, dependency);
+ // The SDK ships prebundled dependencies whose module roots are invisible to Rolldown.
+ if (!dependency.metadata.name.startsWith('@modelcontextprotocol/')) continue;
+ const source = await readFile(moduleId.split('?')[0], 'utf8');
+ for (const match of source.matchAll(/\/\/#[rR]egion [^\n]*\/\.pnpm\/([^/]+)\/node_modules\/(?:@[^/]+\/)?[^/]+\//g)) {
+ const encoded = match[1].split('_')[0];
+ const versionOffset = encoded.lastIndexOf('@');
+ if (versionOffset < 1) continue;
+ const name = encoded.slice(0, versionOffset).replace('+', '/');
+ const version = encoded.slice(versionOffset + 1);
+ if (!/^\d+\.\d+\.\d+/.test(version)) continue;
+ embedded.set(`${name}@${version}`, { name, version, bundledBy: key });
+ }
+ }
+ }
+ const gaps = [];
+ const embeddedNotices = [];
+ for (const [key, dependency] of embedded) {
+ if (dependencies.has(key)) continue;
+ const installed = await packageAt(join(root, 'node_modules', dependency.name));
+ if (installed?.metadata.version === dependency.version) {
+ dependencies.set(key, installed);
+ } else {
+ const filename = join(root, 'licenses', 'mcp', `${dependency.name.replaceAll('/', '_')}-${dependency.version}.txt`);
+ if (existsSync(filename)) {
+ const contents = await readFile(filename, 'utf8');
+ embeddedNotices.push(`## ${key}\n\n${contents}`);
+ dependency.licenseFile = relative(root, filename).replaceAll('\\', '/');
+ dependency.licenseSha256 = digest(Buffer.from(contents));
+ } else {
+ gaps.push({ ...dependency, reason: 'Exact prebundled dependency license is unavailable in installed package roots or licenses/mcp.' });
+ }
+ }
+ }
+ const projectLicense = await readFile(join(root, 'LICENSE'), 'utf8');
+ const notices = [`# MCP bundle licenses\n\n## ${JSON.parse(await readFile(join(root, 'package.json'), 'utf8')).name}\n\n${projectLicense}`];
+ const records = [];
+ for (const [key, dependency] of [...dependencies].sort(([left], [right]) => left.localeCompare(right))) {
+ const filenames = (await readdir(dependency.directory)).filter(name => /^(?:licen[sc]e|copying|notice)(?:[.-].*)?$/i.test(name)).sort();
+ if (!filenames.some(name => /^(?:licen[sc]e|copying)/i.test(name))) {
+ gaps.push({ name: dependency.metadata.name, version: dependency.metadata.version, reason: 'Installed package root has no complete license file.' });
+ }
+ records.push({ name: dependency.metadata.name, version: dependency.metadata.version, license: dependency.metadata.license ?? null, licenseFiles: filenames });
+ for (const filename of filenames) {
+ notices.push(`## ${key}: ${filename}\n\n${await readFile(join(dependency.directory, filename), 'utf8')}`);
+ }
+ }
+ return { text: `${[...notices, ...embeddedNotices].join('\n\n')}\n`, dependencies: records, embeddedDependencies: [...embedded.values()], licenseGaps: gaps };
+}
+
+function singleModule(result, filename, browser) {
+ const outputs = (Array.isArray(result) ? result : [result]).flatMap(bundle => bundle.output);
+ if (outputs.length !== 1 || outputs[0].type !== 'chunk' || !outputs[0].isEntry || outputs[0].fileName !== filename) {
+ throw new Error(`${filename} must be exactly one self-contained entry module, without additional assets or chunks.`);
+ }
+ const chunk = outputs[0];
+ for (const specifier of chunk.imports) {
+ if (browser || (!isBuiltin(specifier) && specifier !== 'playwright-core')) {
+ throw new Error(`${filename} has an unexpected external import: ${specifier}.`);
+ }
+ }
+ for (const specifier of chunk.dynamicImports) {
+ // Rolldown retains a self import to initialize inlined lazy modules without an extra chunk.
+ if (specifier !== filename && (browser || (!isBuiltin(specifier) && specifier !== 'playwright-core'))) {
+ throw new Error(`${filename} has an unexpected dynamic import: ${specifier}.`);
+ }
+ }
+ return chunk;
+}
+
+export async function buildMcp({ outDir = join(root, 'build', 'mcp') } = {}) {
+ const destination = resolve(root, outDir);
+ const offset = relative(root, destination);
+ if (!offset || offset === '..' || offset.startsWith(`..`) || isAbsolute(offset)) {
+ throw new Error('MCP output must be a dedicated subdirectory of the project root.');
+ }
+ setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
+ const { build } = await import('vite');
+ const metadata = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'));
+ const revision = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: root, windowsHide: true, encoding: 'utf8' });
+ if (revision.status !== 0) throw new Error('Git source commit is unavailable. Build from the release checkout.');
+ const status = spawnSync('git', ['status', '--porcelain', '--untracked-files=normal'], { cwd: root, windowsHide: true, encoding: 'utf8' });
+ if (status.status !== 0) throw new Error('Git source status is unavailable. Build from the release checkout.');
+ const configuration = {
+ root,
+ configFile: false,
+ logLevel: 'silent',
+ publicDir: false,
+ build: { write: false, copyPublicDir: false, emptyOutDir: false, outDir: destination, sourcemap: false, minify: true },
+ };
+ const legalBanner = '/*! 67js MCP bundle. Complete license texts and notices: ./LICENSES.md */';
+ const preview = singleModule(await build({
+ ...configuration,
+ build: {
+ ...configuration.build,
+ target: 'es2022',
+ lib: { entry: join(root, 'scripts', 'agent-preview-browser.js'), formats: ['es'], fileName: () => 'preview.js' },
+ rolldownOptions: { platform: 'browser', output: { codeSplitting: false, comments: { legal: true }, banner: legalBanner } },
+ },
+ }), 'preview.js', true);
+ const server = singleModule(await build({
+ ...configuration,
+ resolve: { conditions: ['node', 'import', 'default'], mainFields: ['main', 'module'] },
+ build: {
+ ...configuration.build,
+ target: 'node20',
+ lib: { entry: join(root, 'scripts', 'mcp-server.mjs'), formats: ['es'], fileName: () => 'server.mjs' },
+ rolldownOptions: {
+ platform: 'node',
+ external: specifier => isBuiltin(specifier) || specifier === 'playwright-core',
+ output: { codeSplitting: false, comments: { legal: true }, banner: legalBanner },
+ },
+ },
+ }), 'server.mjs', false);
+ if (!server.exports.includes('createAgentMcpServer') || !server.exports.includes('runMcpCli')) {
+ throw new Error('Node bundle must export createAgentMcpServer and runMcpCli.');
+ }
+ const licenses = await collectLicenses([preview, server]);
+ const files = new Map([['preview.js', preview.code], ['server.mjs', server.code], ['LICENSES.md', licenses.text]]);
+ const outputs = [...files].map(([filename, text]) => {
+ const bytes = Buffer.from(text);
+ return { filename, bytes: bytes.length, sha256: digest(bytes) };
+ });
+ const manifest = {
+ schemaVersion: 1,
+ packageName: metadata.name,
+ packageVersion: metadata.version,
+ sourceCommit: revision.stdout.trim(),
+ sourceDirty: Boolean(status.stdout.trim()),
+ nodeTarget: 'node20',
+ buildTool: { name: 'vite', version: (await packageAt(join(root, 'node_modules', 'vite'))).metadata.version },
+ externalDependencies: [{ name: 'playwright-core', version: (await packageAt(join(root, 'node_modules', 'playwright-core'))).metadata.version }],
+ dependencies: licenses.dependencies,
+ embeddedDependencies: licenses.embeddedDependencies,
+ licenseGaps: licenses.licenseGaps,
+ outputs,
+ };
+ await mkdir(destination, { recursive: true });
+ for (const [filename, contents] of files) {
+ await writeFile(join(destination, filename), contents);
+ }
+ await writeFile(join(destination, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`);
+ for (const gap of licenses.licenseGaps) {
+ console.error(`MCP license gap: ${gap.name}@${gap.version}. ${gap.reason}`);
+ }
+ if (licenses.licenseGaps.length) {
+ throw new Error('MCP build has unresolved license gaps. Inspect manifest.json and supply the exact installed license texts.');
+ }
+ console.error(`Built MCP preview and server for ${metadata.name}@${metadata.version}. Manifest: ${join(destination, 'manifest.json')}`);
+ return manifest;
+}
+
+if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
+ const argumentsList = process.argv.slice(2);
+ if (argumentsList.length && (argumentsList.length !== 2 || argumentsList[0] !== '--out-dir')) {
+ console.error('Use node scripts/build-mcp.mjs [--out-dir <project subdirectory>].');
+ process.exitCode = 1;
+ } else {
+ buildMcp(argumentsList.length ? { outDir: argumentsList[1] } : {}).catch(error => {
+ console.error(error.message);
+ process.exitCode = 1;
+ });
+ }
+}
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjs
index 3a2daacd..19852a97 100644
--- a/scripts/mcp-server.mjs
+++ b/scripts/mcp-server.mjs
@@ -4,6 +4,7 @@ import * as z from 'zod/v4';
import { setPriority, constants } from 'node:os';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
+import packageMetadata from '../package.json' with { type: 'json' };
const finite = z.number().min(-3.4028234663852886e38).max(3.4028234663852886e38);
const positive = finite.positive();
@@ -157,7 +158,7 @@ function jsonResult(value) {
return { content: [{ type: 'text', text: JSON.stringify(value) }], structuredContent: value };
}
-export function createAgentMcpServer(runtime, { version = '0.4.1' } = {}) {
+export function createAgentMcpServer(runtime, { version = packageMetadata.version } = {}) {
const server = new McpServer({ name: '67js-scene', version }, {
instructions: 'Start with scene_capabilities. Create a procedural recipe with scene_create, or select a configured GLB digest from scene_asset_catalog and use scene_create_asset. Inspect stable IDs and save a checkpoint before editing. Apply small batches with the current expectedRevision and check committed, revision and renderSucceeded. Procedural scenes support topology edits; imported assets preserve decoded meshes and support root, material, look and absolute clip sampling. A committed edit can have a separate renderError; do not retry it with an old revision. Use scene_look to judge the actual image. Restore experiments or release unused checkpoints. Export the final recipe and dispose the scene when finished. No arbitrary JavaScript, remote URLs, file paths or jobs are exposed.',
});
@@ -197,9 +198,9 @@ export function createAgentMcpServer(runtime, { version = '0.4.1' } = {}) {
return server;
}
-async function main() {
+export async function runMcpCli({ argumentsValue = process.argv.slice(2),
+ previewUrl = new URL('../build/mcp/preview.js', import.meta.url), version = packageMetadata.version } = {}) {
const options = { backend: 'gpu', memory: 192 };
- const argumentsValue = process.argv.slice(2);
for (let index = 0; index < argumentsValue.length; index += 2) {
const name = argumentsValue[index];
const value = argumentsValue[index + 1];
@@ -213,7 +214,7 @@ async function main() {
}
setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
const { createAgentRuntime } = await import('./agent-runtime.mjs');
- const handle = serveStdio(async () => createAgentMcpServer(await createAgentRuntime(options)), {
+ const handle = serveStdio(() => createAgentMcpServer(createAgentRuntime({ ...options, previewUrl }), { version }), {
transport: new StdioServerTransport(process.stdin, process.stdout, { maxBufferSize: 2 * 1024 * 1024 }),
onerror: error => console.error(`67js MCP error: ${error.message}`),
});
@@ -223,7 +224,7 @@ async function main() {
}
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
- main().catch(error => {
+ runMcpCli().catch(error => {
console.error(error.message);
process.exitCode = 1;
});
diff --git a/scripts/prepare-release.mjs b/scripts/prepare-release.mjs
index 91d96e2b..40841ae3 100644
--- a/scripts/prepare-release.mjs
+++ b/scripts/prepare-release.mjs
@@ -19,6 +19,7 @@ function run(executable, argumentsList, capture = false) {
const commit = run('git', ['rev-parse', 'HEAD'], true);
if (process.argv.includes('--require-clean') && run('git', ['status', '--porcelain'], true)) throw new Error('Commit release changes before production preparation.');
run(process.execPath, ['node_modules/vite/bin/vite.js', 'build', '--config', 'vite.lib.config.js']);
+run(process.execPath, ['scripts/build-mcp.mjs']);
const releases = resolve(root, 'public/releases');
await mkdir(releases, { recursive: true });
const npmCli = process.env.npm_execpath ?? resolve(dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js');
diff --git a/scripts/smoke-agent-assets.mjs b/scripts/smoke-agent-assets.mjs
index ce2f7679..e2ff3e38 100644
--- a/scripts/smoke-agent-assets.mjs
+++ b/scripts/smoke-agent-assets.mjs
@@ -4,20 +4,12 @@ import { constants, setPriority } from 'node:os';
import { resolve } from 'node:path';
import { Client } from '@modelcontextprotocol/client';
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
-import { skinnedStripAsset } from '../tests/fixtures/skinned-strip.js';
+import { createTexturedRigFixture } from './agent-asset-fixture.mjs';
setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
await mkdir('artifacts/asset-catalog-proof', { recursive: true });
await writeFile('artifacts/asset-catalog-proof/wall-e.glb', await readFile('public/wall-e.glb'));
-const texturedDocument = JSON.parse(await readFile('tests/fixtures/textured-triangle.gltf', 'utf8'));
-const image = Buffer.from(texturedDocument.images[0].uri.split(',')[1], 'base64');
-const skinned = skinnedStripAsset((document, append) => {
- append(new Uint8Array(image), 'SCALAR');
- document.images = [{ bufferView: document.bufferViews.length - 1, mimeType: 'image/png' }];
- document.textures = [{ source: 0 }];
- document.materials[0].pbrMetallicRoughness.baseColorTexture = { index: 0 };
-});
-await writeFile('artifacts/asset-catalog-proof/textured-rig.glb', Buffer.from(skinned));
+await writeFile('artifacts/asset-catalog-proof/textured-rig.glb', await createTexturedRigFixture());
const transport = new StdioClientTransport({ command: process.execPath,
args: [resolve('scripts/mcp-server.mjs'), '--backend', 'cpu', '--memory', '192', '--assets', resolve('artifacts/asset-catalog-proof')],
stderr: 'pipe', cwd: process.cwd(),
diff --git a/scripts/smoke-mcp-package.mjs b/scripts/smoke-mcp-package.mjs
new file mode 100644
index 00000000..38064049
--- /dev/null
+++ b/scripts/smoke-mcp-package.mjs
@@ -0,0 +1,162 @@
+import assert from 'node:assert/strict';
+import { mkdtemp, readFile, writeFile, mkdir } from 'node:fs/promises';
+import { existsSync } from 'node:fs';
+import { createHash } from 'node:crypto';
+import { spawnSync } from 'node:child_process';
+import { constants, setPriority, tmpdir } from 'node:os';
+import { resolve, dirname, join } from 'node:path';
+import { performance } from 'node:perf_hooks';
+import { Client } from '@modelcontextprotocol/client';
+import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
+import { createAgentPreviewFixture } from './agent-preview-fixture.mjs';
+import { createTexturedRigFixture } from './agent-asset-fixture.mjs';
+
+setPriority(0, constants.priority.PRIORITY_BELOW_NORMAL);
+const metadata = JSON.parse(await readFile('package.json', 'utf8'));
+const published = process.argv.includes('--published');
+const protocolOnly = process.argv.includes('--protocol-only');
+const consumer = await mkdtemp(join(tmpdir(), '67js-mcp-consumer-'));
+await writeFile(join(consumer, 'package.json'), JSON.stringify({ private: true, type: 'module' }));
+const npmCli = process.env.npm_execpath ?? resolve(dirname(process.execPath), 'node_modules/npm/bin/npm-cli.js');
+function npm(argumentsValue) {
+ const result = spawnSync(process.execPath, [npmCli, ...argumentsValue], { cwd: consumer, windowsHide: true, encoding: 'utf8' });
+ assert.equal(result.status, 0, result.stderr);
+ return result.stdout;
+}
+const packed = JSON.parse(npm(['pack', published ? `${metadata.name}@${metadata.version}` : process.cwd(), '--ignore-scripts', '--json', '--pack-destination', consumer]))[0];
+for (const path of ['bin/67js-mcp.mjs', 'build/mcp/server.mjs', 'build/mcp/preview.js', 'build/mcp/manifest.json', 'build/mcp/LICENSES.md']) {
+ assert.ok(packed.files.some(file => file.path === path), `Packed CLI must contain ${path}.`);
+}
+const archive = join(consumer, packed.filename).replaceAll('\\', '/');
+npm(['install', `67js@file:${archive}`, ...(published ? [] : ['--offline']), '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund']);
+const installedRoot = join(consumer, 'node_modules', '67js');
+const installed = JSON.parse(await readFile(join(installedRoot, 'package.json'), 'utf8'));
+assert.equal(installed.version, metadata.version);
+assert.equal(installed.bin['67js-mcp'], './bin/67js-mcp.mjs');
+assert.deepEqual(installed.dependencies, { 'playwright-core': '1.64.0' });
+for (const dependency of ['vite', 'zod', 'three', 'gl-matrix', '@modelcontextprotocol/server', '@modelcontextprotocol/client', 'playwright']) {
+ assert.equal(existsSync(join(consumer, 'node_modules', dependency)), false, `Runtime must not depend on a checkout or ${dependency}.`);
+}
+assert.equal(existsSync(join(installedRoot, 'src')), false);
+assert.equal(existsSync(join(installedRoot, 'scripts')), false);
+const manifest = JSON.parse(await readFile(join(installedRoot, 'build', 'mcp', 'manifest.json'), 'utf8'));
+assert.equal(manifest.packageVersion, metadata.version);
+assert.deepEqual(manifest.licenseGaps, []);
+if (published) {
+ const revision = spawnSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true });
+ assert.equal(revision.status, 0, revision.stderr);
+ assert.equal(manifest.sourceCommit, revision.stdout.trim());
+ assert.equal(manifest.sourceDirty, false);
+}
+for (const output of manifest.outputs) {
+ assert.ok(['preview.js', 'server.mjs', 'LICENSES.md'].includes(output.filename));
+ const bytes = await readFile(join(installedRoot, 'build', 'mcp', output.filename));
+ assert.equal(bytes.length, output.bytes);
+ assert.equal(createHash('sha256').update(bytes).digest('hex'), output.sha256);
+}
+const cli = join(installedRoot, 'bin', '67js-mcp.mjs');
+const version = spawnSync(process.execPath, [cli, '--version'], { cwd: consumer, encoding: 'utf8', windowsHide: true });
+assert.equal(version.status, 0, version.stderr);
+assert.equal(version.stdout.trim(), metadata.version);
+const help = spawnSync(process.execPath, [cli, '--help'], { cwd: consumer, encoding: 'utf8', windowsHide: true });
+assert.equal(help.status, 0, help.stderr);
+assert.match(help.stdout, /--assets/);
+const invalid = spawnSync(process.execPath, [cli, '--memory', '0'], { cwd: consumer, encoding: 'utf8', windowsHide: true });
+assert.equal(invalid.status, 1);
+assert.equal(invalid.stdout, '');
+assert.match(invalid.stderr, /32 to 256/);
+const shim = join(consumer, 'node_modules', '.bin', process.platform === 'win32' ? '67js-mcp.cmd' : '67js-mcp');
+const shimVersion = process.platform === 'win32'
+ ? spawnSync('cmd.exe', ['/d', '/s', '/c', `""${shim}" --version"`], {
+ cwd: consumer, encoding: 'utf8', windowsHide: true, windowsVerbatimArguments: true,
+ })
+ : spawnSync(shim, ['--version'], { cwd: consumer, encoding: 'utf8' });
+assert.equal(shimVersion.status, 0, shimVersion.stderr);
+assert.equal(shimVersion.stdout.trim(), metadata.version);
+
+const assets = join(consumer, 'assets');
+await mkdir(assets);
+await writeFile(join(assets, 'textured-rig.glb'), await createTexturedRigFixture());
+const results = [];
+for (const era of ['modern', 'legacy']) {
+ const transport = new StdioClientTransport({ command: process.execPath,
+ args: [cli, '--backend', 'cpu', '--memory', '96', '--assets', assets], cwd: consumer, stderr: 'pipe' });
+ let diagnostics = '';
+ transport.stderr.on('data', chunk => { diagnostics += chunk.toString(); });
+ const client = new Client({ name: '67js-installed-cli-proof', version: '1' }, {
+ versionNegotiation: { mode: era === 'modern' ? { pin: '2026-07-28' } : 'legacy', probe: { timeoutMs: 180000 } },
+ });
+ let processId;
+ async function call(name, argumentsValue = {}) {
+ const result = await client.callTool({ name, arguments: argumentsValue }, { timeout: 60000 });
+ assert.equal(result.isError, undefined, result.content?.find(item => item.type === 'text')?.text);
+ return result;
+ }
+ async function image(sessionId) {
+ const result = await call('scene_look', { sessionId, width: 512, height: 512 });
+ assert.match(result.structuredContent.graphics, /SwiftShader/);
+ assert.ok(result.structuredContent.estimatedBytes < 96 * 1024 * 1024);
+ const bytes = Buffer.from(result.content.find(item => item.type === 'image').data, 'base64');
+ assert.deepEqual(bytes.subarray(0, 8), Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));
+ return bytes;
+ }
+ try {
+ const start = performance.now();
+ await client.connect(transport, { timeout: 180000 });
+ const connectMs = performance.now() - start;
+ processId = transport.pid;
+ assert.equal(client.getServerVersion().version, metadata.version);
+ assert.equal((await client.listTools()).tools.length, 12);
+ const capabilities = (await call('scene_capabilities')).structuredContent;
+ assert.equal(capabilities.phase, 'idle');
+ assert.equal(capabilities.preview.maximumActiveScenes, 1);
+ assert.equal(capabilities.availableIn, metadata.version);
+ if (protocolOnly) {
+ results.push({ era, tools: 12, connectMs, browserStarted: false });
+ } else {
+ const created = (await call('scene_create', { recipe: createAgentPreviewFixture() })).structuredContent;
+ const before = await image(created.sessionId);
+ const checkpoint = (await call('scene_checkpoint', { sessionId: created.sessionId })).structuredContent;
+ await call('scene_apply', { sessionId: created.sessionId, expectedRevision: 0,
+ operations: [{ type: 'set-environment', environment: { keyIntensity: 2 } }] });
+ assert.notDeepEqual(await image(created.sessionId), before);
+ await call('scene_restore', { sessionId: created.sessionId, expectedRevision: 1, checkpointId: checkpoint.checkpointId });
+ assert.deepEqual(await image(created.sessionId), before);
+ await call('scene_dispose', { sessionId: created.sessionId });
+ const catalog = (await call('scene_asset_catalog')).structuredContent;
+ assert.equal(catalog.assets.length, 1);
+ const rig = (await call('scene_create_asset', { recipe: { format: '67js.asset', schemaVersion: 1, assetId: catalog.assets[0].assetId,
+ camera: { eye: [1, 3, 7], target: [1, 3, 0], fov: 35, near: 0.1, far: 40 } } })).structuredContent;
+ assert.equal(rig.render.materialTextures, 1);
+ assert.equal(rig.render.skinTextures, 1);
+ const initial = await image(rig.sessionId);
+ const sampled = (await call('scene_apply', { sessionId: rig.sessionId, expectedRevision: 0,
+ operations: [{ type: 'set-animation', clip: 0, time: 1.1 }] })).structuredContent;
+ assert.equal(sampled.renderSucceeded, true);
+ assert.equal(sampled.render.gpuBuffers, rig.render.gpuBuffers);
+ const bent = await image(rig.sessionId);
+ assert.notDeepEqual(bent, initial);
+ await call('scene_apply', { sessionId: rig.sessionId, expectedRevision: 1, operations: [{ type: 'set-animation', time: 0.4 }] });
+ await call('scene_apply', { sessionId: rig.sessionId, expectedRevision: 2, operations: [{ type: 'set-animation', time: 1.1 }] });
+ assert.deepEqual(await image(rig.sessionId), bent);
+ const exported = (await call('scene_export_recipe', { sessionId: rig.sessionId })).structuredContent;
+ assert.equal(exported.recipe.animation.time, 1.1);
+ await mkdir('artifacts', { recursive: true });
+ await writeFile(`artifacts/mcp-package-${era}.png`, bent);
+ results.push({ era, tools: 12, connectMs, importedTexture: true, importedSkin: true, undoPngExact: true, reverseSeekPngExact: true });
+ // Keep the final rig active to prove EOF closes its renderer and owned browser.
+ }
+ } finally {
+ await client.close();
+ }
+ assert.match(diagnostics, /67js preview resources closed\./);
+ assert.doesNotMatch(diagnostics, /cleanup failed|shutdown failed/);
+ assert.throws(() => process.kill(processId, 0), /ESRCH/);
+}
+const report = { packageName: metadata.name, version: metadata.version, archiveBytes: packed.size,
+ published, protocolOnly,
+ runtimeDevelopmentDependencies: false, nativeShimVersion: true, builtOutputHashesMatch: true,
+ sourceCommit: manifest.sourceCommit, eofWithActiveScene: !protocolOnly, results };
+await mkdir('artifacts', { recursive: true });
+await writeFile(`artifacts/mcp-package-${published ? 'published' : protocolOnly ? 'protocol' : 'cpu'}.json`, JSON.stringify(report, null, 2));
+console.log(JSON.stringify(report));
diff --git a/skills/build-67js-scene/references/scene-contract.md b/skills/build-67js-scene/references/scene-contract.md
index a5244b94..3bd0ddd2 100644
--- a/skills/build-67js-scene/references/scene-contract.md
+++ b/skills/build-67js-scene/references/scene-contract.md
@@ -133,7 +133,7 @@ Bind immutable geometry once. This sparse point attachment does not deform the a
The surface-attachment addon is included in npm `0.4.1`.
Agent authoring uses `createAgentScene(recipe, limits)` from `67js/addons/agent-scene`.
-This addon is available in source after npm `0.4.1`; it is not included in that published package.
+This addon is included in npm `0.5.0` and later.
Read `docs/agent-scene.md` for schema version one, immutable resources and atomic topology commands.
Start with capabilities and bounded inspection. Edit stable IDs through one `apply` batch with the current `expectedRevision`.
Checkpoint before uncertain changes, inspect and render the result, then restore or release the checkpoint.
@@ -145,7 +145,7 @@ Keep JSON commands and snapshots exposed to agents; retained matrices and immuta
Do not inspect all vertex bounds in a frame loop. Memory estimates cover unique geometry arrays, not total RAM or VRAM.
The scene addon does not implement MCP transport, asset search, animation authoring, or render jobs.
-For a configured MCP client, use the separate source-only server documented in `docs/mcp.md`.
+For a configured MCP client, use the packaged `67js-mcp` server documented in `docs/mcp.md`.
Call `scene_capabilities`, create one JSON scene, inspect IDs, checkpoint, apply a small batch, and assess `scene_look` PNG content.
Use the revision returned by each committed apply or restore. A response with `committed: true` and `renderSucceeded: false` still advances revision.
Inspect or export the canonical recipe after a render failure; do not retry the edit with its old revision.
@@ -156,7 +156,7 @@ Use `scene_create_asset` with a `67js.asset` recipe; supported texture maps, ski
Edit imported models through `set-root`, factor-only `set-material`, look commands and absolute `set-animation` sampling. Imported topology is immutable.
Use `{ type: 'set-animation', time }` to sample the current clip; `{ type: 'set-animation', clip: null }` restores the decoded pose.
Bounds describe authored base geometry, not the deformed skin/morph silhouette. Check the rendered PNG before accepting framing.
-Read `docs/agent-look.md` for authored lighting, fog, effects and shadow coverage, available after npm `0.4.1`.
+Read `docs/agent-look.md` for authored lighting, fog, effects and shadow coverage, included in npm `0.5.0`.
Use atomic `set-environment`, `set-effects` and `set-shadow` partial records instead of editing renderer internals through MCP.
Nested volumeFog/bloom fields merge; pointLights replaces the full list. Point lights do not cast local shadows.
Volume fog requires opaque HDR/depth rendering. The preview adapter allocates depth support at creation and rejects unsupported fog before commit.