copy_column_layout
Copy column layouts between DEVONthink smart groups or smart rules to maintain consistent display settings for document organization.
Instructions
Copy the column layout (column order, visible columns, and column widths) from one DEVONthink smart group or smart rule to another. All three layout keys are copied atomically. Supports partial name matching. Input: { "sourceName": "Archivieren - Jobs", "targetName": "Jobs - To Review" }
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceName | Yes | Name of the source smart group or smart rule (must have a saved layout) | |
| targetName | Yes | Name of the target smart group or smart rule to copy the layout to | |
| sourceUuid | No | Optional UUID of the source smart group (fallback if name lookup fails). DEVONthink sometimes stores layouts under the UUID. | |
| targetUuid | No | Optional UUID of the target smart group. If supplied, the layout is written under the UUID key (which DEVONthink prefers for smart groups). |
Implementation Reference
- Handler for copy_column_layout, logic to read source layout and write it to target.
const copyColumnLayout = async (args: Record<string, unknown>): Promise<CopyColumnLayoutResult> => { const sourceName = args.sourceName as string | undefined; const targetName = args.targetName as string | undefined; const sourceUuid = args.sourceUuid as string | undefined; const targetUuid = args.targetUuid as string | undefined; if (!sourceName || typeof sourceName !== "string") { return { success: false, error: "sourceName parameter is required" }; } if (!targetName || typeof targetName !== "string") { return { success: false, error: "targetName parameter is required" }; } let resolvedSourceKey: string | null = null; if (readLayoutForName(sourceName)) { resolvedSourceKey = sourceName; } else if (sourceUuid && readLayoutForName(sourceUuid)) { resolvedSourceKey = sourceUuid; } else { const fuzzy = findMatchingNames(sourceName); if (fuzzy.length === 1 && readLayoutForName(fuzzy[0])) { resolvedSourceKey = fuzzy[0]; } else if (fuzzy.length > 1) { return { success: false, sourceName, targetName, error: `Ambiguous source name "${sourceName}". Multiple matches: ${fuzzy.slice(0, 8).join(", ")}`, }; } } if (!resolvedSourceKey) { const examples = getExistingNames(10); return { success: false, sourceName, targetName, error: `Source column layout for "${sourceName}" not found. ` + "This smart group may not have a custom layout saved yet. " + `Known layouts include: ${examples.slice(0, 8).join(", ")}`, }; } const resolvedTargetKey = targetUuid ?? targetName; const copyResult = copyPlistKeys(PLIST_PATH, LAYOUT_SUFFIXES, resolvedSourceKey, resolvedTargetKey); if (!copyResult.ok) { return { success: false, sourceName, targetName, resolvedSourceKey, resolvedTargetKey, error: `Copy failed: ${copyResult.error}`, }; } const verification = readLayoutForName(resolvedTargetKey); if (!verification) { return { success: false, sourceName, targetName, resolvedSourceKey, resolvedTargetKey, error: "Copy appeared to succeed but target keys not readable after write", }; } return { success: true, sourceName, targetName, resolvedSourceKey, resolvedTargetKey, keysCopied: copyResult.keysCopied, message: `Copied column layout from "${sourceName}" to "${targetName}". ` + `Keys written: ${copyResult.keysCopied.join(", ")}. ` + `Columns: [${verification.columns?.join(", ") ?? "n/a"}]. ` + "Restart DEVONthink or close/reopen the smart group window for the change to take effect.", }; }; - src/tools/custom/column-layout.ts:284-319 (registration)Registration of the copy_column_layout tool.
export const copyColumnLayoutTool: McpTool = { name: "copy_column_layout", description: "Copy the column layout (column order, visible columns, and column widths) from one " + "DEVONthink smart group or smart rule to another. " + "All three layout keys are copied atomically. Supports partial name matching. " + 'Input: { "sourceName": "Archivieren - Jobs", "targetName": "Jobs - To Review" }', inputSchema: { type: "object" as const, properties: { sourceName: { type: "string", description: "Name of the source smart group or smart rule (must have a saved layout)", }, targetName: { type: "string", description: "Name of the target smart group or smart rule to copy the layout to", }, sourceUuid: { type: "string", description: "Optional UUID of the source smart group (fallback if name lookup fails). " + "DEVONthink sometimes stores layouts under the UUID.", }, targetUuid: { type: "string", description: "Optional UUID of the target smart group. If supplied, the layout is written " + "under the UUID key (which DEVONthink prefers for smart groups).", }, }, required: ["sourceName", "targetName"], additionalProperties: false, }, run: copyColumnLayout, };