Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_list_files_in_dir

List files and directories in a specific Obsidian vault folder to discover content structure and locate documents.

Instructions

Lists all files and directories that exist in a specific Obsidian directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dirpathYesPath to list files from (relative to your vault root). Note that empty directories will not be returned.

Implementation Reference

  • The run_tool method implements the core tool logic: it validates the 'dirpath' argument, calls the Obsidian API to list files in the directory, and returns the results as JSON-formatted text content.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
    
        if "dirpath" not in args:
            raise RuntimeError("dirpath argument missing in arguments")
    
        files = api.list_files_in_dir(args["dirpath"])
    
        return [
            TextContent(
                type="text",
                text=json.dumps(files, indent=2)
            )
        ]
  • Defines the tool's schema, including the name 'obsidian_list_files_in_dir', description, and input schema requiring a 'dirpath' string parameter.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Lists all files and directories that exist in a specific Obsidian directory.",
            inputSchema={
                "type": "object",
                "properties": {
                    "dirpath": {
                        "type": "string",
                        "description": "Path to list files from (relative to your vault root). Note that empty directories will not be returned."
                    },
                },
                "required": ["dirpath"]
            }
        )
  • TOOL_MAPPING dictionary maps the tool name constant TOOL_LIST_FILES_IN_DIR ("obsidian_list_files_in_dir") to the ListFilesInDirToolHandler class. This mapping is used in register_tools() to instantiate and register the handler with the MCP server.
    TOOL_MAPPING = {
        tools.TOOL_LIST_FILES_IN_DIR: tools.ListFilesInDirToolHandler,
        tools.TOOL_SIMPLE_SEARCH: tools.SearchToolHandler,
        tools.TOOL_PATCH_CONTENT: tools.PatchContentToolHandler,
        tools.TOOL_PUT_CONTENT: tools.PutContentToolHandler,
        tools.TOOL_APPEND_CONTENT: tools.AppendContentToolHandler,
        tools.TOOL_DELETE_FILE: tools.DeleteFileToolHandler,
        tools.TOOL_COMPLEX_SEARCH: tools.ComplexSearchToolHandler,
        tools.TOOL_BATCH_GET_FILES: tools.BatchGetFilesToolHandler,
        tools.TOOL_PERIODIC_NOTES: tools.PeriodicNotesToolHandler,
        tools.TOOL_RECENT_PERIODIC_NOTES: tools.RecentPeriodicNotesToolHandler,
        tools.TOOL_RECENT_CHANGES: tools.RecentChangesToolHandler,
        tools.TOOL_UNDERSTAND_VAULT: tools.UnderstandVaultToolHandler,
        tools.TOOL_GET_ACTIVE_NOTE: tools.GetActiveNoteToolHandler,
        tools.TOOL_OPEN_FILES: tools.OpenFilesToolHandler,
        tools.TOOL_LIST_COMMANDS: tools.ListCommandsToolHandler,
        tools.TOOL_EXECUTE_COMMANDS: tools.ExecuteCommandsToolHandler,
    }
  • register_tools() function instantiates handler classes from TOOL_MAPPING for selected tools (including obsidian_list_files_in_dir if not filtered out) and adds them to the tool_handlers dictionary used by list_tools() and call_tool(). Called at startup.
    def register_tools():
        """Register the selected tools with the server."""
        tools_to_include = parse_include_tools()
        
        registered_count = 0
        for tool_name in tools_to_include:
            if tool_name in TOOL_MAPPING:
                handler_class = TOOL_MAPPING[tool_name]
                handler_instance = handler_class()
                add_tool_handler(handler_instance)
                registered_count += 1
                logger.debug(f"Registered tool: {tool_name}")
        
        logger.info(f"Successfully registered {registered_count} tools")
  • Constant defining the exact tool name string "obsidian_list_files_in_dir" used throughout for registration and identification.
    TOOL_LIST_FILES_IN_DIR = "obsidian_list_files_in_dir"
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions that 'empty directories will not be returned' (via schema), which is useful, but lacks other behavioral details like permissions needed, rate limits, output format, pagination, or error conditions. For a tool with no annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence with zero waste—front-loaded with the core action and scope. Every word earns its place, making it highly efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no annotations, no output schema), the description is minimally adequate but has clear gaps. It covers the basic purpose but lacks usage guidance, behavioral context, and output details, which are needed for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents the single parameter 'dirpath'. The description adds no additional parameter semantics beyond what's in the schema, such as path format examples or edge cases. Baseline 3 is appropriate when schema does all the work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Lists') and resource ('all files and directories') with specific scope ('in a specific Obsidian directory'). It distinguishes from some siblings like search tools but doesn't explicitly differentiate from 'obsidian_batch_get_files' or 'obsidian_open_files' which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives like 'obsidian_simple_search', 'obsidian_complex_search', or 'obsidian_batch_get_files'. The description implies directory-focused listing but doesn't specify use cases, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/ToKiDoO/mcp-obsidian-advanced'

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