lock_elements
Prevent accidental edits by locking selected elements in Excalidraw diagrams to maintain layout integrity during collaborative work.
Instructions
Lock elements to prevent modification
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"elementIds": "<elementIds>"
},
"name": "lock_elements"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementIds | Yes |
Implementation Reference
- src/index.js:536-550 (handler)Handler for the 'lock_elements' tool: parses input elementIds, sets locked=true on each existing element, and returns confirmation.
case 'lock_elements': { const params = ElementIdsSchema.parse(args); const { elementIds } = params; elementIds.forEach(id => { const element = elements.get(id); if (element) { element.locked = true; } }); const result = { locked: true, elementIds }; return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; - src/index.js:52-54 (schema)Zod schema defining the input for lock_elements (and similar tools): an object with elementIds array.
const ElementIdsSchema = z.object({ elementIds: z.array(z.string()) }); - src/index.js:241-252 (registration)Registration of 'lock_elements' tool in MCP server capabilities, including input schema.
lock_elements: { description: 'Lock elements to prevent modification', inputSchema: { type: 'object', properties: { elementIds: { type: 'array', items: { type: 'string' } } }, required: ['elementIds'] } - src/index.js:814-825 (registration)Tool schema returned in ListToolsRequestHandler for 'lock_elements'.
name: 'lock_elements', description: 'Lock elements to prevent modification', inputSchema: { type: 'object', properties: { elementIds: { type: 'array', items: { type: 'string' } } }, required: ['elementIds'] } - src/index.js:30-46 (schema)General ElementSchema including 'locked' boolean field, used across tools.
const ElementSchema = z.object({ type: z.enum(Object.values(EXCALIDRAW_ELEMENT_TYPES)), x: z.number(), y: z.number(), width: z.number().optional(), height: z.number().optional(), points: z.array(z.object({ x: z.number(), y: z.number() })).optional(), backgroundColor: z.string().optional(), strokeColor: z.string().optional(), strokeWidth: z.number().optional(), roughness: z.number().optional(), opacity: z.number().optional(), text: z.string().optional(), fontSize: z.number().optional(), fontFamily: z.number().optional(), locked: z.boolean().optional() // ADDED: Make sure locked status is saved });