Skip to main content
Glama
MarkusPfundstein

MCP server for Obsidian

obsidian_list_files_in_dir

List files and directories within a specific Obsidian vault folder to manage and navigate your notes.

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 ListFilesInDirToolHandler class is the core handler for the 'obsidian_list_files_in_dir' tool. It defines the tool's schema (inputSchema for 'dirpath') and implements the run_tool method, which calls the Obsidian API to list files in the specified directory and returns the JSON-formatted result.
    class ListFilesInDirToolHandler(ToolHandler):
        def __init__(self):
            super().__init__(TOOL_LIST_FILES_IN_DIR)
    
        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"]
                }
            )
    
        def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
    
            if "dirpath" not in args:
                raise RuntimeError("dirpath argument missing in arguments")
    
            api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
    
            files = api.list_files_in_dir(args["dirpath"])
    
            return [
                TextContent(
                    type="text",
                    text=json.dumps(files, indent=2)
                )
            ]
  • Registers the ListFilesInDirToolHandler instance in the tool_handlers dictionary, making the 'obsidian_list_files_in_dir' tool available to the MCP server.
    add_tool_handler(tools.ListFilesInDirToolHandler())
  • The Obsidian client's list_files_in_dir method performs the HTTP GET request to the Obsidian API endpoint '/vault/{dirpath}/' to retrieve the list of files and directories in the specified path.
    def list_files_in_dir(self, dirpath: str) -> Any:
        url = f"{self.get_base_url()}/vault/{dirpath}/"
        
        def call_fn():
            response = requests.get(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
            response.raise_for_status()
            
            return response.json()['files']
    
        return self._safe_call(call_fn)
  • Defines the constant string for the tool name used in the handler initialization.
    TOOL_LIST_FILES_IN_DIR = "obsidian_list_files_in_dir"
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the core function (listing files/directories) and notes that empty directories are not returned (via schema description), but does not disclose other behavioral traits such as permissions needed, rate limits, output format, pagination, or error handling. It adds some context but leaves significant gaps for a tool with no annotation coverage.

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?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and scope, making it easy to parse. Every part of the sentence contributes essential information, earning its place with zero waste.

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 no annotations, no output schema, and a simple single-parameter input schema, the description provides basic completeness for a read-only listing tool. However, it lacks details on output structure (e.g., format of returned list), error conditions, or integration with sibling tools. It is minimally viable but has clear gaps in contextual information that could aid an AI agent.

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%, with the single parameter 'dirpath' fully documented in the schema (path relative to vault root, empty directories not returned). The description does not add any parameter-specific semantics beyond what the schema provides, such as format examples or edge cases. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 sibling 'obsidian_list_files_in_vault' by specifying directory-level rather than vault-wide listing, though not explicitly named. The purpose is unambiguous but could be more explicit about the sibling distinction.

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

Usage Guidelines3/5

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

The description implies usage context (directory-level listing) but does not explicitly state when to use this tool versus alternatives like 'obsidian_list_files_in_vault' or file-content tools. It provides no guidance on prerequisites, exclusions, or comparative scenarios. The context is clear but lacks explicit alternative naming or when-not-to-use advice.

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

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