-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathrig-mesh.js
More file actions
77 lines (70 loc) · 2.74 KB
/
Copy pathrig-mesh.js
File metadata and controls
77 lines (70 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// `rig_mesh` — paid MCP tool: static GLB → rigged, animation-ready GLB.
//
// Pricing: $0.20 USDC, settled `exact` on Solana.
//
// Takes a GLB mesh URL and returns a rigged GLB — a humanoid skeleton plus
// per-vertex skin weights — produced by the three.ws auto-rig pipeline
// (/api/forge?action=rig, VAST-AI UniRig by default). Like mesh_forge, this is
// a thin x402-gated client over the prod pipeline: it holds no generation
// credentials; the USDC payment gates the call and all GPU work runs on
// three.ws prod.
//
// The rig logic lives in `_studio-core.js` (runRigMesh) so the paid stdio
// transport and the hosted FREE 3D Studio endpoint (api/_studio,
// /api/mcp-studio) share ONE implementation and never drift.
//
// Environment (all optional — sensible prod defaults):
// MESH_FORGE_API_BASE — three.ws origin. Default https://three.ws
// RIG_MESH_TIMEOUT_MS — overall rig poll budget. Default 180000.
// RIG_MESH_POLL_MS — poll interval. Default 3000.
import { z } from 'zod';
import { paid } from '../payments.js';
import { jsonSchemaFromZod } from './_shared.js';
import { runRigMesh } from './_studio-core.js';
const TOOL_NAME = 'rig_mesh';
const TOOL_DESCRIPTION =
'Auto-rig a static 3D GLB mesh into an animation-ready model: adds a humanoid skeleton and per-vertex skin weights via the three.ws rig pipeline (VAST-AI UniRig by default). Takes a GLB URL, returns the rigged GLB URL and a three.ws pose-studio link. Pairs with mesh_forge — forge a mesh, then rig it. Paid: $0.20 USDC.';
const inputZodShape = {
glb_url: z
.string()
.url()
.describe('http(s) URL to the static GLB mesh to rig (e.g. the glbUrl returned by mesh_forge).'),
};
const inputJsonSchema = jsonSchemaFromZod(inputZodShape);
export async function buildRigMeshTool() {
const handler = await paid(
{
toolName: TOOL_NAME,
description: TOOL_DESCRIPTION,
scheme: 'exact',
priceUsd: '$0.20',
inputSchema: inputJsonSchema,
example: { glb_url: 'https://three.ws/cdn/creations/abc123/mesh.glb' },
outputExample: {
ok: true,
riggedGlbUrl: 'https://three.ws/cdn/creations/def456/rigged.glb',
sourceGlbUrl: 'https://three.ws/cdn/creations/abc123/mesh.glb',
poseStudioUrl: 'https://three.ws/pose?src=https%3A%2F%2Fthree.ws%2F...',
jobId: 'r9k2m7x4',
creationId: 'def456',
durationMs: 48000,
},
},
(args) => runRigMesh(args),
);
return {
name: TOOL_NAME,
title: 'Rig 3D mesh ($0.20)',
description: TOOL_DESCRIPTION,
inputSchema: inputZodShape,
// Creates a new hosted rigged-GLB artifact via external rigging APIs;
// the input mesh is never modified or deleted.
annotations: {
readOnlyHint: false,
destructiveHint: false,
idempotentHint: false,
openWorldHint: true,
},
handler,
};
}