Skip to main content
Glama
j-shelfwood

Obsidian Local REST API MCP Server

by j-shelfwood

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
NameRequiredDescriptionDefault
pathNoDirectory path to list.
recursiveNoInclude subdirectories recursively
limitNoMaximum items to return
offsetNoPagination offset

Implementation Reference

  • 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 }, }, }, },
  • 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;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/j-shelfwood/obsidian-local-rest-api-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server