List Folders
list_foldersRetrieve a comprehensive list of folders from all accounts, each with its note count.
Instructions
List all folders across all accounts with note counts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folders | Yes |
Implementation Reference
- src/notes/tools.ts:330-362 (registration)Registration of the 'list_folders' tool in the MCP server, defining its input/output schemas and the handler that calls listFoldersScript() via JXA and filters shared access.
server.registerTool( "list_folders", { title: "List Folders", description: "List all folders across all accounts with note counts.", inputSchema: {}, outputSchema: { folders: z.array( z.object({ id: z.string(), name: z.string(), account: z.string(), noteCount: z.number(), shared: z.boolean(), }), ), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async () => { try { const result = await runJxa<FolderItem[]>(listFoldersScript()); return okStructured({ folders: filterSharedAccess(result, config, "notes") }); } catch (e) { return errJxaFor("list folders", e); } }, ); - src/notes/tools.ts:354-361 (handler)The async handler function for list_folders tool: runs the JXA script and returns filtered folders.
async () => { try { const result = await runJxa<FolderItem[]>(listFoldersScript()); return okStructured({ folders: filterSharedAccess(result, config, "notes") }); } catch (e) { return errJxaFor("list folders", e); } }, - src/notes/scripts.ts:215-237 (helper)listFoldersScript() function that returns a JXA script string to list all folders across accounts with their names, note counts, and shared status.
export function listFoldersScript(): string { return ` const Notes = Application('Notes'); const accounts = Notes.accounts(); const result = []; for (const acct of accounts) { const aName = acct.name(); const fIds = acct.folders.id(); const fNames = acct.folders.name(); const fShared = acct.folders.shared(); for (let i = 0; i < fIds.length; i++) { result.push({ id: fIds[i], name: fNames[i], account: aName, noteCount: acct.folders[i].notes.length, shared: fShared[i] }); } } JSON.stringify(result); `; } - src/notes/tools.ts:335-346 (schema)Output schema for list_folders: an array of folders with id, name, account, noteCount, and shared fields.
inputSchema: {}, outputSchema: { folders: z.array( z.object({ id: z.string(), name: z.string(), account: z.string(), noteCount: z.number(), shared: z.boolean(), }), ), },