Skip to main content
Glama
YanceyOfficial

Obsidian iCloud MCP

list_directory

Retrieve a detailed directory listing from Obsidian iCloud MCP, distinguishing files and directories with [FILE] and [DIR] prefixes. Essential for navigating and identifying specific items within your Obsidian vault.

Instructions

Your task is to list directory under /Users/username/Library/Mobile Documents/iCloud~md~obsidian/Documents/my-vault. Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The handler function for the list_directory tool. It validates input using ListDirectoryArgsSchema, reads directory contents with fs.readdir, formats entries as [DIR] or [FILE], and returns formatted text.
    export async function listDirectory(args?: Record<string, unknown>) { const parsed = ListDirectoryArgsSchema.safeParse(args) if (!parsed.success) { throw new Error(`Invalid arguments for list_directory: ${parsed.error}`) } const entries = await fs.readdir(parsed.data.path, { withFileTypes: true }) const formatted = entries .map((entry) => `${entry.isDirectory() ? '[DIR]' : '[FILE]'} ${entry.name}`) .join('\n') return { content: [{ type: 'text', text: formatted }] } }
  • Zod schema defining the input for list_directory: an object with 'path' string.
    export const ListDirectoryArgsSchema = z.object({ path: z.string() })
  • src/index.ts:136-139 (registration)
    Tool registration in ListToolsRequestHandler: defines name, description (from prompt), and inputSchema.
    name: 'list_directory', description: listDirectoryPrompt(args), inputSchema: zodToJsonSchema(ListDirectoryArgsSchema) as ToolInput },
  • src/index.ts:199-201 (registration)
    Handler dispatch in CallToolRequestHandler switch: calls listDirectory on tool invocation.
    case 'list_directory': { return listDirectory(args) }
  • Prompt generator for the list_directory tool description, including root paths and usage instructions.
    export const listDirectoryPrompt = (rootPaths: string[]) => `Your task is to list directory under ${rootPaths.join(', ')}. ` + 'Get a detailed listing of all files and directories in a specified path. ' + 'Results clearly distinguish between files and directories with [FILE] and [DIR] ' + 'prefixes. This tool is essential for understanding directory structure and ' + 'finding specific files within a directory. Only works within allowed directories.'

Other Tools

Related Tools

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

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