Skip to main content
Glama

obsidian_list_files_in_vault

View the top-level structure of your Obsidian vault to understand organization and locate folders for Zettelkasten notes.

Instructions

List all files and directories in the vault root.

This tool shows the top-level structure of your Obsidian vault, helping you
understand the organization and locate folders for Zettelkasten notes.

Returns:
    str: Formatted list of directories and files in the vault root
    
Example:
    Returns a markdown-formatted list showing all top-level folders and files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Registration of the obsidian_list_files_in_vault tool using @mcp.tool decorator with name and annotations.
    @mcp.tool(
        name="obsidian_list_files_in_vault",
        annotations={
            "title": "List Files in Vault Root",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
  • Handler function implementing the core logic: calls ObsidianClient.get('/vault/') to retrieve files and directories, formats them using format_file_list, handles errors.
    async def list_files_in_vault() -> str:
        """List all files and directories in the vault root.
        
        This tool shows the top-level structure of your Obsidian vault, helping you
        understand the organization and locate folders for Zettelkasten notes.
        
        Returns:
            str: Formatted list of directories and files in the vault root
            
        Example:
            Returns a markdown-formatted list showing all top-level folders and files.
        """
        try:
            result = await obsidian_client.get("/vault/")
            files = result.get("files", [])
            directories = result.get("directories", [])
            
            return format_file_list(files, directories)
            
        except ObsidianAPIError as e:
            return json.dumps({
                "error": str(e),
                "success": False
            }, indent=2)
  • Helper function that formats the lists of files and directories into a markdown-formatted response for the user.
    def format_file_list(files: List[str], directories: List[str]) -> str:
        """Format file and directory lists for display."""
        result = []
        
        if directories:
            result.append("## Directories")
            for d in sorted(directories):
                result.append(f"- ๐Ÿ“ {d}/")
            result.append("")
        
        if files:
            result.append("## Files")
            for f in sorted(files):
                result.append(f"- ๐Ÿ“„ {f}")
        
        return "\n".join(result) if result else "No files or directories found."

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

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