add_layer
Add a new layer to a pixel art project for organizing elements, enabling separate editing of components like foreground, background, or animation frames.
Instructions
Add a new layer to the project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier | |
| layerName | No | Name for the new layer |
Implementation Reference
- src/server/PiskelServer.ts:957-975 (handler)Implementation of the 'add_layer' tool handler.
private addLayer(projectId: string, layerName?: string): object { const piskel = this.getProject(projectId); const name = layerName ?? `Layer ${piskel.getLayerCount()}`; const layer = new Layer(name); // Add frames to match existing frame count const frameCount = piskel.getFrameCount(); for (let i = 0; i < frameCount; i++) { layer.addFrame(new Frame(piskel.getWidth(), piskel.getHeight())); } piskel.addLayer(layer); return { success: true, layerIndex: piskel.getLayerCount() - 1, layerName: name, }; } - src/server/PiskelServer.ts:145-162 (registration)Registration of the 'add_layer' tool in the Piskel MCP Server.
{ name: 'add_layer', description: 'Add a new layer to the project', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'Project identifier', }, layerName: { type: 'string', description: 'Name for the new layer', }, }, required: ['projectId'], }, },