list_notes
Retrieve and filter notes from Apple Notes with titles, folders, dates, pinned status, and snippets. Use folder filtering and result limits to organize your notes.
Instructions
List notes from Apple Notes. Returns title, folder, dates, pinned status, snippet. Optionally filter by folder name and limit results.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | No | Filter by folder name | |
| limit | No | Max number of notes to return |
Implementation Reference
- src/db.ts:51-74 (handler)The implementation of the logic to query and list notes from the Apple Notes database.
export function listNotes(folder?: string, limit?: number): NoteRow[] { const db = getDb(); let sql = LIST_QUERY; const params: unknown[] = []; if (folder) { sql = sql.replace( "ORDER BY", "AND f.ZTITLE2 = ? ORDER BY" ); params.push(folder); } if (limit) { sql += ` LIMIT ?`; params.push(limit); } const rows = db.prepare(sql).all(...params) as NoteRow[]; return rows.map((r) => ({ ...r, is_pinned: Boolean(r.is_pinned), })); } - src/index.ts:19-40 (registration)The registration of the 'list_notes' MCP tool and its handler invocation in src/index.ts.
// --- list_notes --- server.tool( "list_notes", "List notes from Apple Notes. Returns title, folder, dates, pinned status, snippet. Optionally filter by folder name and limit results.", { folder: z.string().optional().describe("Filter by folder name"), limit: z.number().optional().describe("Max number of notes to return"), }, async ({ folder, limit }) => { try { const notes = listNotes(folder, limit); return { content: [{ type: "text", text: JSON.stringify(notes, null, 2) }], }; } catch (e: unknown) { return { content: [{ type: "text", text: `Error: ${(e as Error).message}` }], isError: true, }; } } );