3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Import the motion track kinds from a leaf module in the MCP server (#2128)
Nguyen Xuan An20e92cc8b75c
diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex 848272ec..c8455d87 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -1,5 +1,5 @@import { answerCapabilities, MAX_TOPICS_PER_CALL } from './capabilities-topics.mjs';-import { MOTION_TRACK_KINDS } from '../src/agent-motion.js';+import { MOTION_TRACK_KIND_NAMES } from '../src/motion-track-kinds.js';import { BRANCH_NAME_PATTERN } from '../src/agent-branches.js';import { TEXTURE_SEQUENCE_LIMITS } from '../src/texture-sequence-limits.js';import { readEnvironmentVariable } from '../src/environment-variable.js';@@ -629,7 +629,7 @@ const motionTrackProperties = {geometry: ['oceanTime'],};// The backend's list, so scene_create and set-motion accept the same kinds.-const motionTrackKinds = MOTION_TRACK_KINDS;+const motionTrackKinds = MOTION_TRACK_KIND_NAMES;const motionTrackFields = ['kind', 'id', 'property', 'interpolation', 'keyframes', 'extrapolation', 'modifiers'];// A union reports only "Invalid input"; name the field and the allowed ones the way set-motion does.function motionTrackUnionMessage(issue) {diff --git a/src/motion-track-kinds.js b/src/motion-track-kinds.jsnew file mode 100644index 00000000..9a0aa9c9--- /dev/null+++ b/src/motion-track-kinds.js@@ -0,0 +1,3 @@+// The kinds a motion track may have, in a leaf module so the MCP server can import the list without bundling the motion code.+// tests/mcp-recipe-round-trip.test.js checks it equals MOTION_TRACK_KINDS of src/agent-motion.js.+export const MOTION_TRACK_KIND_NAMES = Object.freeze(['node', 'material', 'camera', 'morph', 'geometry', 'light', 'sun', 'environment', 'effects']);diff --git a/tests/mcp-recipe-round-trip.test.js b/tests/mcp-recipe-round-trip.test.jsindex 96eb9751..4bba7315 100644--- a/tests/mcp-recipe-round-trip.test.js+++ b/tests/mcp-recipe-round-trip.test.js@@ -6,6 +6,7 @@ import { InMemoryTransport } from '@modelcontextprotocol/server';import { createAgentMcpServer } from '../scripts/mcp-server.mjs';import { walkerRecipe } from '../bench/agent-modeling/walker.mjs';import { MOTION_TRACK_KINDS } from '../src/agent-motion.js';+import { MOTION_TRACK_KIND_NAMES } from '../src/motion-track-kinds.js';import { createAgentScene, loadPhysicsEngine, AGENT_SCENE_CAPABILITIES } from '../src/agent-scene.js';await loadPhysicsEngine();@@ -222,6 +223,7 @@ test('scene_create accepts a morph motion track and the shape key weight animate});test('scene_create takes every motion track kind the backend lists', async () => {+ assert.deepEqual([...MOTION_TRACK_KIND_NAMES], [...MOTION_TRACK_KINDS], 'the MCP leaf list matches the motion backend');assert.deepEqual([...MOTION_TRACK_KINDS], ['node', 'material', 'camera', 'morph', 'geometry', 'light', 'sun', 'environment', 'effects']);await withRoundTripClient(async client => {const wrongKind = await call(client, 'scene_create', { recipe: oneBoxRecipe({ motion: { duration: 1, tracks: [{ kind: 'sky', id: 'a', property: 'x', keyframes: [{ time: 0, value: 0 }] }] } }) });