list_directory
List directory contents with pagination to prevent overload. Specify path, recursion, and limits to retrieve files efficiently within an Obsidian vault using a local REST API.
Instructions
List directory contents with pagination to prevent context overflow. Shows immediate contents by default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum items to return | |
| offset | No | Pagination offset | |
| path | No | Directory path to list | . |
| recursive | No | Include subdirectories recursively |
Implementation Reference
- src/index.ts:101-109 (handler)Core implementation of the list_directory tool in ObsidianApiClient. Makes a paginated GET request to the Obsidian REST API /vault/directory endpoint.async listDirectory(path: string = ".", recursive: boolean = false, limit: number = 50, offset: number = 0) { const params = new URLSearchParams({ path, recursive: recursive.toString(), limit: limit.toString(), offset: offset.toString(), }); return this.request(`/vault/directory?${params}`); }
- src/index.ts:276-287 (schema)Input schema and metadata definition for the list_directory tool, registered in ListToolsRequestSchema handler.name: "list_directory", description: "List directory contents with pagination to prevent context overflow. Shows immediate contents by default.", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory path to list", default: "." }, recursive: { type: "boolean", description: "Include subdirectories recursively", default: false }, limit: { type: "number", description: "Maximum items to return", default: 50 }, offset: { type: "number", description: "Pagination offset", default: 0 }, }, }, },
- src/index.ts:451-458 (registration)Tool handler registration in the MCP CallToolRequestSchema switch dispatcher, mapping tool calls to the client.listDirectory method.case "list_directory": result = await this.client.listDirectory( args?.path as string, args?.recursive as boolean, args?.limit as number, args?.offset as number ); break;