keynote_set_element_position
Move any text, image, or shape element on a Keynote slide to a new position by specifying x and y coordinates in points from the top-left corner.
Instructions
Move an element to a new position on the slide. Coordinates are in points from the top-left corner. Keynote standard slide is 1920×1080 pts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_index | No | Document index (0-based). Defaults to 0 (frontmost). | |
| slide_index | Yes | Slide index (0-based). | |
| element_type | Yes | Element collection to target. | |
| element_index | Yes | Element index within its collection (0-based). | |
| x | Yes | Horizontal position in points (from left edge). | |
| y | Yes | Vertical position in points (from top edge). |
Implementation Reference
- src/keynote-jxa.ts:342-360 (handler)The actual JXA handler that executes 'set_element_position'. It gets the document, slide, and element, then sets the element's position. It verifies the change and returns a helpful error if the element is a locked master-layout placeholder.
case 'set_element_position': { var doc = getDoc(app, payload.doc_index); var el = getElement(getSlide(doc, payload.slide_index), payload.element_type, payload.element_index); try { el.position = [payload.x, payload.y]; // Verify it actually changed var verify = safeCall(function() { return el.position(); }, null); if (verify && Math.abs(verify[0] - payload.x) < 2 && Math.abs(verify[1] - payload.y) < 2) { return { updated: true, position: { x: payload.x, y: payload.y } }; } return { updated: false, locked: true, reason: 'This element is a layout placeholder controlled by the master slide. Its position cannot be changed via scripting. To move it: open Keynote, edit the master slide (View > Edit Master Slides), or duplicate the slide and add a free text box instead.' }; } catch (e) { throw new Error('Cannot move this element — it is likely a master-layout placeholder. ' + (e.message || '')); } } - src/keynote-tooling.ts:127-142 (schema)The tool definition with input schema for 'keynote_set_element_position'. Defines required parameters: slide_index, element_type, element_index, x, y. Also optional doc_index.
{ name: 'keynote_set_element_position', description: 'Move an element to a new position on the slide. Coordinates are in points from the top-left corner. Keynote standard slide is 1920×1080 pts.', inputSchema: { type: 'object', properties: { doc_index: ELEMENT_FIELDS.doc_index, slide_index: ELEMENT_FIELDS.slide_index, element_type: ELEMENT_FIELDS.element_type, element_index: ELEMENT_FIELDS.element_index, x: { type: 'number', description: 'Horizontal position in points (from left edge).' }, y: { type: 'number', description: 'Vertical position in points (from top edge).' }, }, required: ['slide_index', 'element_type', 'element_index', 'x', 'y'], }, }, - src/index.ts:167-177 (registration)The MCP tool registration/dispatch in the main server file. Maps 'keynote_set_element_position' to bridge.execute('set_element_position', ...) with argument extraction.
case 'keynote_set_element_position': { const result = await bridge.execute('set_element_position', { doc_index: optionalNumber(args.doc_index), slide_index: requireNumber(args.slide_index, 'slide_index'), element_type: requireString(args.element_type, 'element_type'), element_index: requireNumber(args.element_index, 'element_index'), x: requireNumber(args.x, 'x'), y: requireNumber(args.y, 'y'), }); return jsonResult(result); }