createObject
Add 3D objects like cubes, spheres, cylinders, and lights to Spline scenes with custom positioning, rotation, and scaling for 3D design projects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sceneId | Yes | Scene ID | |
| type | Yes | Object type | |
| name | Yes | Object name | |
| position | No | Object position | |
| rotation | No | Object rotation | |
| scale | No | Object scale | |
| color | No | Object color (hex) | |
| properties | No | Additional properties |
Implementation Reference
- src/tools/object-tools.js:101-133 (handler)The MCP tool handler for 'createObject' that constructs the object data from parameters and calls the API client to create the object in the scene, returning success or error response.async ({ sceneId, type, name, position, rotation, scale, color, properties }) => { try { const objectData = { type, name, position: position || { x: 0, y: 0, z: 0 }, rotation: rotation || { x: 0, y: 0, z: 0 }, scale: scale || { x: 1, y: 1, z: 1 }, ...(color && { color }), ...(properties && { properties }), }; const result = await apiClient.createObject(sceneId, objectData); return { content: [ { type: 'text', text: `Object created successfully with ID: ${result.id}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error creating object: ${error.message}` } ], isError: true }; }
- src/tools/object-tools.js:76-100 (schema)Zod schema defining the input parameters for the createObject tool, including sceneId, type, name, position, rotation, scale, color, and properties.{ sceneId: z.string().min(1).describe('Scene ID'), type: z.enum([ 'cube', 'sphere', 'cylinder', 'cone', 'torus', 'plane', 'text', 'image', 'group', 'light' ]).describe('Object type'), name: z.string().min(1).describe('Object name'), position: z.object({ x: z.number().default(0).describe('X position'), y: z.number().default(0).describe('Y position'), z: z.number().default(0).describe('Z position'), }).optional().describe('Object position'), rotation: z.object({ x: z.number().default(0).describe('X rotation (degrees)'), y: z.number().default(0).describe('Y rotation (degrees)'), z: z.number().default(0).describe('Z rotation (degrees)'), }).optional().describe('Object rotation'), scale: z.object({ x: z.number().default(1).describe('X scale'), y: z.number().default(1).describe('Y scale'), z: z.number().default(1).describe('Z scale'), }).optional().describe('Object scale'), color: z.string().optional().describe('Object color (hex)'), properties: z.record(z.any()).optional().describe('Additional properties'), },
- src/tools/object-tools.js:74-135 (registration)The server.tool call that registers the 'createObject' MCP tool with its schema and handler within the registerObjectTools function.server.tool( 'createObject', { sceneId: z.string().min(1).describe('Scene ID'), type: z.enum([ 'cube', 'sphere', 'cylinder', 'cone', 'torus', 'plane', 'text', 'image', 'group', 'light' ]).describe('Object type'), name: z.string().min(1).describe('Object name'), position: z.object({ x: z.number().default(0).describe('X position'), y: z.number().default(0).describe('Y position'), z: z.number().default(0).describe('Z position'), }).optional().describe('Object position'), rotation: z.object({ x: z.number().default(0).describe('X rotation (degrees)'), y: z.number().default(0).describe('Y rotation (degrees)'), z: z.number().default(0).describe('Z rotation (degrees)'), }).optional().describe('Object rotation'), scale: z.object({ x: z.number().default(1).describe('X scale'), y: z.number().default(1).describe('Y scale'), z: z.number().default(1).describe('Z scale'), }).optional().describe('Object scale'), color: z.string().optional().describe('Object color (hex)'), properties: z.record(z.any()).optional().describe('Additional properties'), }, async ({ sceneId, type, name, position, rotation, scale, color, properties }) => { try { const objectData = { type, name, position: position || { x: 0, y: 0, z: 0 }, rotation: rotation || { x: 0, y: 0, z: 0 }, scale: scale || { x: 1, y: 1, z: 1 }, ...(color && { color }), ...(properties && { properties }), }; const result = await apiClient.createObject(sceneId, objectData); return { content: [ { type: 'text', text: `Object created successfully with ID: ${result.id}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `Error creating object: ${error.message}` } ], isError: true }; } } );
- src/index.js:88-88 (registration)Top-level registration call in the main server setup that invokes registerObjectTools(server), thereby registering the createObject tool.registerObjectTools(server);
- src/utils/api-client.js:94-96 (helper)Helper method in the API client that performs the actual HTTP POST request to the Spline.design API to create a new object.async createObject(sceneId, objectData) { return this.request('POST', `/scenes/${sceneId}/objects`, objectData); }