list_directory
Browse directory contents with pagination to manage large folders and avoid context overflow in Obsidian vaults.
Instructions
List directory contents with pagination to prevent context overflow. Shows immediate contents by default.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Directory path to list | . |
| recursive | No | Include subdirectories recursively | |
| limit | No | Maximum items to return | |
| offset | No | Pagination offset |
Implementation Reference
- src/index.ts:101-109 (handler)The core handler function that implements the list_directory tool logic by constructing query parameters and making an HTTP GET request to the Obsidian REST API endpoint `/vault/directory`.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 (registration)Registers the list_directory tool in the MCP server's tool list, including its name, description, and detailed input schema for parameters.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 (handler)Dispatch handler in the MCP CallToolRequestHandler that routes 'list_directory' tool calls to the ObsidianApiClient.listDirectory method with type-cast arguments.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;