Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(mcp): agents can pick animation clips by measured motion
nirholasff6851d5ec31
diff --git a/api/_mcp/tools/animations.js b/api/_mcp/tools/animations.jsindex b5df03be7..6929325b6 100644--- a/api/_mcp/tools/animations.js+++ b/api/_mcp/tools/animations.js@@ -24,6 +24,13 @@ import {MIN_COVERAGE,} from '../../../src/animation-retarget.js';import { categoryOf } from '../../../src/animation-presets.js';+import {+ describe as describeSignature,+ energyBand,+ similarTo,+ slotFit,+} from '../../../src/runtime/motion-signature.js';+import { SLOTS, DEFAULT_ANIMATION_MAP } from '../../../src/runtime/animation-slots.js';// Largest base64-encoded GLB we'll inline in a JSON-RPC response before falling// back to the (small) clip JSON. Keeps responses sane for very heavy avatars.@@ -46,6 +53,14 @@ async function loadManifest(origin) {return manifest;}+async function loadSignatures(origin) {+ const res = await fetch(`${origin}/animations/signatures.json`, { cache: 'no-store' });+ if (!res.ok) throw new Error(`signatures fetch failed (HTTP ${res.status})`);+ const index = await res.json();+ if (!index?.clips || !Object.keys(index.clips).length) throw new Error('signature index is empty');+ return index;+}+async function loadClipJSON(origin, def) {// def.url is a site-relative path like /animations/clips/idle.jsonconst res = await fetch(`${origin}${def.url}`, { cache: 'no-store' });@@ -205,6 +220,108 @@ export const toolDefs = [};},},+ {+ name: 'animation_signature',+ title: 'Measure what an animation clip actually does',+ // Reads the platform's own measured index (public/animations/signatures.json,+ // generated by scripts/build-motion-signatures.mjs): deterministic, closed-world.+ annotations: {+ readOnlyHint: true,+ destructiveHint: false,+ idempotentHint: true,+ openWorldHint: false,+ },+ description:+ 'The measured motion signature of a baked clip: energy, tempo, which body region leads, loop-seam cleanliness, root travel, and whether it survives as an upper-body overlay. Pass `slot` to also get a fit verdict ("ok" or "warn" with the reason) for playing this clip in that runtime slot (idle, wave, fidget and the rest). Use it to pick clips by what they do rather than by name.',+ inputSchema: {+ type: 'object',+ required: ['clip'],+ properties: {+ clip: {+ type: 'string',+ description: 'Clip name from list_animations (e.g. "idle", "wave", "av-conductor").',+ },+ slot: {+ type: 'string',+ description: 'Optional runtime slot to check the clip against (e.g. "idle", "fidget", "wave").',+ },+ },+ additionalProperties: false,+ },+ async handler(args, auth, req) {+ const origin = resolveOrigin(req);+ const index = await loadSignatures(origin);+ const sig = index.clips[String(args.clip)];+ if (!sig) {+ throw rpcError(-32602, `No signature for "${args.clip}". Use list_animations for valid names.`);+ }+ let fit = null;+ if (args.slot !== undefined) {+ const slot = String(args.slot);+ if (!SLOTS.includes(slot)) {+ throw rpcError(-32602, `"${slot}" is not a runtime slot. Slots: ${SLOTS.join(', ')}.`);+ }+ fit = { slot, defaultClip: DEFAULT_ANIMATION_MAP[slot] ?? slot, ...slotFit(slot, sig) };+ }+ const text = [+ `${sig.clip}: ${describeSignature(sig)}`,+ ...(fit ? [`Fit for "${fit.slot}": ${fit.level}. ${fit.message}`] : []),+ ].join('\n');+ return {+ content: [{ type: 'text', text }],+ structuredContent: { signature: { ...sig, band: energyBand(sig) }, ...(fit ? { fit } : {}) },+ };+ },+ },+ {+ name: 'find_similar_animations',+ title: 'Find clips with similar measured motion',+ // Pure arithmetic over the same measured index as animation_signature.+ annotations: {+ readOnlyHint: true,+ destructiveHint: false,+ idempotentHint: true,+ openWorldHint: false,+ },+ description:+ 'Rank the library\'s clips by measured-motion distance from a reference clip (regional shares, energy, tempo, travel). Use it for "more like this": alternatives when a clip does not fit a slot, or variety without changing the mood.',+ inputSchema: {+ type: 'object',+ required: ['clip'],+ properties: {+ clip: {+ type: 'string',+ description: 'Reference clip name from list_animations.',+ },+ limit: {+ type: 'integer',+ minimum: 1,+ maximum: 20,+ description: 'How many neighbors to return (default 5).',+ },+ },+ additionalProperties: false,+ },+ async handler(args, auth, req) {+ const origin = resolveOrigin(req);+ const index = await loadSignatures(origin);+ if (!index.clips[String(args.clip)]) {+ throw rpcError(-32602, `No signature for "${args.clip}". Use list_animations for valid names.`);+ }+ const limit = Math.max(1, Math.min(20, Number.parseInt(args.limit ?? 5, 10) || 5));+ const matches = similarTo(String(args.clip), index.clips, limit).map((m) => ({+ clip: m.clip,+ distance: Math.round(m.distance * 1000) / 1000,+ band: energyBand(m.signature),+ description: describeSignature(m.signature),+ }));+ const lines = matches.map((m) => ` ${m.clip.padEnd(24)} d=${m.distance} [${m.band}] ${m.description}`);+ return {+ content: [{ type: 'text', text: `${matches.length} clips nearest to ${args.clip}:\n${lines.join('\n')}` }],+ structuredContent: { clip: String(args.clip), similar: matches },+ };+ },+ },{name: 'apply_animation',title: 'Apply an animation preset to a rigged model',diff --git a/docs/mcp-3d-studio.md b/docs/mcp-3d-studio.mdindex 78e788e40..e570fe744 100644--- a/docs/mcp-3d-studio.md+++ b/docs/mcp-3d-studio.md@@ -42,6 +42,8 @@ analyze: inspect_model · optimize_model preview: preview_3d| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ || `auto_rig_model(glb_url)` | Add a humanoid skeleton + per-vertex skin weights to a static GLB (VAST-AI UniRig). Returns a `job_id`; poll for the rigged GLB. || `list_animations(category?)` | The curated, retargetable animation-clip catalogue (names, categories, loop flags). |+| `animation_signature(clip, slot?)` | A clip's measured motion: energy, tempo, leading region, loop seam, travel. Pass `slot` for an ok/warn fit verdict against a runtime slot. |+| `find_similar_animations(clip, limit?)` | The library ranked by measured-motion distance from a reference clip: "more like this" for animations. || `apply_animation(model_url, animation, format?, speed?)` | Retarget a preset clip onto a rigged GLB — returns the retargeted `AnimationClip` JSON (or a baked animated GLB). || `pose_model(prompt)` | Map a pose description to a deterministic seed + full Euler joint-rotation map from the in-repo preset library. Free, deterministic. |@@ -168,7 +170,7 @@ For tool calls there are two lanes:| `auto_rig_model`, `retexture_model`, `retexture_region` | $0.05 || `stylize_model`, `remesh_model`, `segment_model` | $0.02 || `remove_background`, `pose_model`, `apply_animation`, `direct_prompt`, `generate_material` | $0.01 |-| `generation_status`, `preview_3d`, `list_animations`, `inspect_model`, `optimize_model`, `getting_started` | free |+| `generation_status`, `preview_3d`, `list_animations`, `animation_signature`, `find_similar_animations`, `inspect_model`, `optimize_model`, `getting_started` | free |Payment settles only after the work succeeds — a wholesale failure costsnothing, and the same signed payment cannot be replayed.diff --git a/public/mcp-catalog.json b/public/mcp-catalog.jsonindex 6ef250e1e..26c8b36f1 100644--- a/public/mcp-catalog.json+++ b/public/mcp-catalog.json@@ -2,15 +2,15 @@"$comment": "Generated by scripts/build-mcp-catalog.mjs from the tool definitions and price maps in this repo. Do not edit by hand: npm run build:mcp-catalog regenerates it and npm run audit:mcp-catalog fails the build when it is stale.","docs": "https://three.ws/docs/mcp-safety","counts": {- "tools": 272,+ "tools": 274,"servers": 36,- "free": 244,+ "free": 246,"paid": 28,- "read": 183,+ "read": 185,"write": 70,"irreversible": 19,- "withSchema": 272,- "withArguments": 250+ "withSchema": 274,+ "withArguments": 252},"servers": [{@@ -227,7 +227,7 @@"endpoint": "/api/mcp","transport": "remote","auth": "oauth-or-x402",- "tools": 45+ "tools": 47},{"id": "threews-3d-studio",@@ -8057,6 +8057,47 @@},"source": "packages/three-token-mcp/src/tools/three-price.js"},+ {+ "name": "animation_signature",+ "title": "Measure what an animation clip actually does",+ "description": "The measured motion signature of a baked clip: energy, tempo, which body region leads, loop-seam cleanliness, root travel, and whether it survives as an upper-body overlay. Pass `slot` to also get a fit verdict (\"ok\" or \"warn\" with the reason) for playing this clip in that runtime slot (idle, wave, fidget and the rest). Use it to pick clips by what they do rather than by name.",+ "server": {+ "id": "three.ws",+ "title": "three.ws",+ "endpoint": "/api/mcp",+ "transport": "remote",+ "auth": "oauth-or-x402"+ },+ "safety": "read",+ "annotations": {+ "readOnlyHint": true,+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": false+ },+ "price": {+ "usd": 0,+ "free": true+ },+ "inputSchema": {+ "type": "object",+ "properties": {+ "clip": {+ "type": "string",+ "description": "Clip name from list_animations (e.g. \"idle\", \"wave\", \"av-conductor\")."+ },+ "slot": {+ "type": "string",+ "description": "Optional runtime slot to check the clip against (e.g. \"idle\", \"fidget\", \"wave\")."+ }+ },+ "required": [+ "clip"+ ],+ "additionalProperties": false+ },+ "source": "api/_mcp/tools/animations.js"+ },{"name": "apply_animation","title": "Apply an animation preset to a rigged model",@@ -8507,6 +8548,49 @@},"source": "api/_mcp/tools/avatars.js"},+ {+ "name": "find_similar_animations",+ "title": "Find clips with similar measured motion",+ "description": "Rank the library's clips by measured-motion distance from a reference clip (regional shares, energy, tempo, travel). Use it for \"more like this\": alternatives when a clip does not fit a slot, or variety without changing the mood.",+ "server": {+ "id": "three.ws",+ "title": "three.ws",+ "endpoint": "/api/mcp",+ "transport": "remote",+ "auth": "oauth-or-x402"+ },+ "safety": "read",+ "annotations": {+ "readOnlyHint": true,+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": false+ },+ "price": {+ "usd": 0,+ "free": true+ },+ "inputSchema": {+ "type": "object",+ "properties": {+ "clip": {+ "type": "string",+ "description": "Reference clip name from list_animations."+ },+ "limit": {+ "type": "integer",+ "minimum": 1,+ "maximum": 20,+ "description": "How many neighbors to return (default 5)."+ }+ },+ "required": [+ "clip"+ ],+ "additionalProperties": false+ },+ "source": "api/_mcp/tools/animations.js"+ },{"name": "forget","title": "Forget",diff --git a/tests/fixtures/mcp-golden-tools.json b/tests/fixtures/mcp-golden-tools.jsonindex ef834f606..487302346 100644--- a/tests/fixtures/mcp-golden-tools.json+++ b/tests/fixtures/mcp-golden-tools.json@@ -117,6 +117,19 @@}],"api/_mcp/tools/animations.js": [+ {+ "name": "animation_signature",+ "title": "Measure what an animation clip actually does",+ "descHead": "The measured motion signature of a baked clip: energy, tempo, which body",+ "descHash": "b6be349c0653",+ "annotations": {+ "readOnlyHint": true,+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": false+ },+ "schemaHash": "7bf0d491e1fc"+ },{"name": "apply_animation","title": "Apply an animation preset to a rigged model",@@ -130,6 +143,19 @@},"schemaHash": "ae2a6528b1ba"},+ {+ "name": "find_similar_animations",+ "title": "Find clips with similar measured motion",+ "descHead": "Rank the library's clips by measured-motion distance from a reference cl",+ "descHash": "4e1e1b4079fc",+ "annotations": {+ "readOnlyHint": true,+ "destructiveHint": false,+ "idempotentHint": true,+ "openWorldHint": false+ },+ "schemaHash": "81f2be06fbe3"+ },{"name": "list_animations","title": "List animation presets",