Clear Selection
photopea_clear_selectionRemove the current selection in your Photopea document to clear marching ants after completing selection-based operations like fills or adjustments. Leaves pixel data unchanged.
Instructions
Deselect the current selection in the active document, removing the marching ants. Does not modify any pixel data. Use after fill_selection or other selection-based operations are complete.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/image.ts:237-243 (handler)The async handler function that executes the clear selection logic: builds the script via buildClearSelection(), sends activity, executes the script, and returns success/error.
}, async (_params) => { const script = buildClearSelection(); bridge.sendActivity({ type: "activity", id: "", tool: "clear_selection", summary: "Clear selection" }); const result = await bridge.executeScript(script); if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to clear selection" }] }; return { content: [{ type: "text" as const, text: "Selection cleared" }] }; }); - src/tools/image.ts:232-243 (registration)Registration of the 'photopea_clear_selection' tool with MCP server, including title, description, empty inputSchema, and annotations.
server.registerTool("photopea_clear_selection", { title: "Clear Selection", description: "Deselect the current selection in the active document, removing the marching ants. Does not modify any pixel data. Use after fill_selection or other selection-based operations are complete.", inputSchema: {}, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async (_params) => { const script = buildClearSelection(); bridge.sendActivity({ type: "activity", id: "", tool: "clear_selection", summary: "Clear selection" }); const result = await bridge.executeScript(script); if (!result.success) return { isError: true, content: [{ type: "text" as const, text: result.error || "Failed to clear selection" }] }; return { content: [{ type: "text" as const, text: "Selection cleared" }] }; }); - src/tools/image.ts:235-235 (schema)Input schema is empty object ({}) - this tool takes no parameters.
inputSchema: {}, - src/bridge/script-builder.ts:796-798 (helper)Helper function buildClearSelection() that generates the Photoshop/Photopea script to deselect the current selection.
export function buildClearSelection(): string { return `app.activeDocument.selection.deselect();\napp.echoToOE('ok');`; } - src/tools/image.ts:13-15 (helper)Import of buildClearSelection from the script-builder module.
buildClearSelection, escapeString, } from "../bridge/script-builder.js";