Skip to main content
Glama
sureshsankaran

Obsidian Tools MCP Server

list_folder

List all notes and subfolders within a specified folder in your Obsidian vault. Use this tool to organize and navigate your vault structure by viewing contents at any directory level.

Instructions

List all notes and subfolders in a folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoFolder path relative to vault root. Use empty string for vault root
recursiveNoWhether to list recursively. Default: false

Implementation Reference

  • The handler function that implements the core logic for the 'list_folder' tool. It reads the directory at the given path, lists .md notes and subfolders, and recursively lists subfolders if specified, returning a JSON object with notes and folders arrays.
    async function handleListFolder(args: { path?: string; recursive?: boolean; }): Promise<string> { const folderPath = path.join(VAULT_PATH, args.path || ""); const recursive = args.recursive ?? false; if (!(await fileExists(folderPath))) { throw new Error(`Folder not found at ${args.path}`); } const entries = await fs.readdir(folderPath, { withFileTypes: true }); const result: { notes: string[]; folders: string[] } = { notes: [], folders: [], }; for (const entry of entries) { if (entry.name.startsWith(".")) continue; if (entry.isDirectory()) { result.folders.push(entry.name); if (recursive) { const subResult = await handleListFolder({ path: path.join(args.path || "", entry.name), recursive: true, }); const parsed = JSON.parse(subResult); result.notes.push( ...parsed.notes.map((n: string) => path.join(entry.name, n)) ); } } else if (entry.isFile() && entry.name.endsWith(".md")) { result.notes.push(entry.name); } } return JSON.stringify(result, null, 2); }
  • src/index.ts:208-227 (registration)
    The tool definition object in the 'tools' array used for registration. Includes the name, description, and input schema, returned by ListToolsRequest.
    name: "list_folder", description: "List all notes and subfolders in a folder", inputSchema: { type: "object", properties: { path: { type: "string", description: "Folder path relative to vault root. Use empty string for vault root", default: "", }, recursive: { type: "boolean", description: "Whether to list recursively. Default: false", default: false, }, }, required: [], }, },
  • src/index.ts:906-910 (registration)
    The switch case in the main CallToolRequest handler that dispatches calls to the 'list_folder' tool to its handler function.
    case "list_folder": result = await handleListFolder( args as { path?: string; recursive?: boolean } ); break;
  • The input schema defining the parameters for the 'list_folder' tool: optional path (string) and recursive (boolean).
    type: "object", properties: { path: { type: "string", description: "Folder path relative to vault root. Use empty string for vault root", default: "", }, recursive: { type: "boolean", description: "Whether to list recursively. Default: false", default: false, }, }, required: [], },

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/sureshsankaran/obsidian-tools-mcp'

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