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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/custom_obsidian_mcp/server.py:396-405 (registration)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."