List Notes By Folder
dataview.listByFolderList all notes in a specified vault folder, with optional filtering, sorting, and limit using Dataview queries.
Instructions
Convenience wrapper that runs LIST FROM "folder" (optionally with WHERE, SORT, and LIMIT clauses). Useful when you want every note under a vault folder. Requires the Dataview and Local REST API plugins.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | Yes | Vault-relative folder to filter by. | |
| whereClause | No | Optional DQL `WHERE` clause body (without the `WHERE` keyword). | |
| sortBy | No | Optional DQL `SORT` clause body (without the `SORT` keyword). Example: `file.ctime desc`. | |
| limit | No | Optional `LIMIT` n clause. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/domain/api-tools.ts:80-94 (handler)The actual handler function `listNotesByFolderDql` that builds a TABLE query from the folder argument and optional WHERE/SORT/LIMIT clauses, then delegates to `executeDataviewQuery`.
export async function listNotesByFolderDql( context: DomainContext, args: { folder: string; whereClause?: string; sortBy?: string; limit?: number }, ) { const query = [ "TABLE file.name", `FROM "${args.folder}"`, args.whereClause ? `WHERE ${args.whereClause}` : "", args.sortBy ? `SORT ${args.sortBy}` : "", args.limit ? `LIMIT ${args.limit}` : "", ] .filter(Boolean) .join(" "); return executeDataviewQuery(context, { query }); } - src/schema/dataview.ts:39-46 (schema)Zod schema for the tool's input arguments: required `folder` (string) plus optional `whereClause`, `sortBy`, and `limit` via `sharedDqlFields`.
export const dataviewListByFolderArgsSchema = z .object({ folder: z.string().min(1).describe("Vault-relative folder to filter by."), ...sharedDqlFields, }) .strict() .describe('Sugar wrapper around `LIST FROM "folder"`.'); export type DataviewListByFolderArgs = z.input<typeof dataviewListByFolderArgsSchema>; - src/server/tools/dataview.ts:66-78 (registration)Tool definition registration: sets name `dataview.listByFolder`, title, description, input/output schemas, annotations, and the handler that parses args and calls `listNotesByFolderDql`. Exported as part of the `dataviewTools` array.
{ name: "dataview.listByFolder", title: "List Notes By Folder", description: 'Convenience wrapper that runs `LIST FROM "folder"` (optionally with `WHERE`, `SORT`, and `LIMIT` clauses). Useful when you want every note under a vault folder. Requires the Dataview and Local REST API plugins.', inputSchema: dataviewListByFolderArgsSchema, outputSchema: looseObjectSchema, annotations: READ_ONLY_OPEN_WORLD, handler: async (context, rawArgs) => { const args = dataviewListByFolderArgsSchema.parse(rawArgs) as DataviewListByFolderArgs; return listNotesByFolderDql(context, args); }, },