list_smart_rules
Enumerate DEVONthink smart rules by parsing SmartRules.plist to retrieve names, UUIDs, enabled states, and execution timestamps when standard APIs are unavailable.
Instructions
List all DEVONthink smart rules by parsing SmartRules.plist. Returns name, UUID (from sync.UUID), enabled state, indexOffset, lastExecution timestamp, and sync date for each rule. Smart rules are NOT accessible via the standard AppleScript API — this is the only way to enumerate them.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The handler function 'listSmartRules' that parses the DEVONthink SmartRules.plist file and returns the list of smart rules.
const listSmartRules = async (): Promise<SmartRulesResult> => { if (!existsSync(PLIST_PATH)) { return { success: false, error: `SmartRules.plist not found at: ${PLIST_PATH}. Ensure DEVONthink has been run at least once and smart rules have been created.`, }; } let xml: string; try { xml = execSync(`plutil -convert xml1 -o - "${PLIST_PATH}"`, { encoding: "utf-8", timeout: 10000, }); } catch (err) { return { success: false, error: `Failed to parse SmartRules.plist: ${err instanceof Error ? err.message : String(err)}`, }; } let smartRules: SmartRuleEntry[]; try { smartRules = parsePlistXmlToSmartRules(xml); } catch (err) { return { success: false, error: `Failed to parse XML output from plutil: ${err instanceof Error ? err.message : String(err)}`, }; } smartRules.sort((a, b) => a.name.localeCompare(b.name)); return { success: true, smartRules, totalCount: smartRules.length }; }; - src/tools/custom/list-smart-rules.ts:115-128 (registration)The MCP tool object 'listSmartRulesTool' which registers the 'list_smart_rules' name and associates it with the 'listSmartRules' handler.
export const listSmartRulesTool: McpTool = { name: "list_smart_rules", description: "List all DEVONthink smart rules by parsing SmartRules.plist. " + "Returns name, UUID (from sync.UUID), enabled state, indexOffset, lastExecution timestamp, " + "and sync date for each rule. " + "Smart rules are NOT accessible via the standard AppleScript API — this is the only way to enumerate them.", inputSchema: { type: "object" as const, properties: {}, additionalProperties: false, }, run: listSmartRules, };