Skip to main content
Glama
dot-RealityTest

obsidian-codex-mcp

get_folder_structure

Retrieve the entire folder hierarchy of an Obsidian vault to understand its organization.

Instructions

Get the complete folder structure of the vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • server.py:293-300 (registration)
    MCP tool registration for get_folder_structure in server.py using the @mcp.tool() decorator. It delegates to the client's get_folder_structure method.
    @mcp.tool()
    def get_folder_structure() -> dict:
        """Get the complete folder structure of the vault."""
        try:
            client = get_vault_client()
            return client.get_folder_structure()
        except Exception as e:
            return {"error": str(e)}
  • Core handler implementation. Recursively walks the vault directory, skipping hidden files, collecting .md files as 'note' type and subdirectories as 'folder' type with nested children.
    def get_folder_structure(self) -> Dict[str, Any]:
        """Get the complete folder structure of the vault."""
        structure = {'name': self.vault_path.name, 'type': 'folder', 'children': []}
        
        def build_structure(current_path: Path, current_node: Dict):
            for item in sorted(current_path.iterdir()):
                if item.name.startswith('.'):
                    continue
                
                if item.is_file() and item.suffix.lower() == '.md':
                    current_node['children'].append({
                        'name': item.name,
                        'type': 'note',
                        'path': str(item.relative_to(self.vault_path))
                    })
                elif item.is_dir():
                    folder_node = {
                        'name': item.name,
                        'type': 'folder',
                        'path': str(item.relative_to(self.vault_path)),
                        'children': []
                    }
                    current_node['children'].append(folder_node)
                    build_structure(item, folder_node)
        
        build_structure(self.vault_path, structure)
        return structure
  • Helper function that lazily initializes and returns the ObsidianVaultClient singleton, used by the tool handler.
    def get_vault_client() -> ObsidianVaultClient:
        """Get or create the vault client."""
        global _vault_client, _vault_path
        
        if _vault_client is None:
            if _vault_path is None:
                # Try to get from environment variable
                _vault_path = os.getenv("OBSIDIAN_VAULT_PATH")
                if not _vault_path:
                    raise ValueError("Obsidian vault path not configured. Set OBSIDIAN_VAULT_PATH environment variable.")
            
            _vault_client = ObsidianVaultClient(_vault_path, backup_on_write=backup_on_write_enabled())
            logger.info(f"Connected to vault: {_vault_path}")
        
        return _vault_client
Behavior2/5

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

No annotations are provided. The description does not disclose whether the structure is flat or nested, whether empty folders are included, or any ordering. More context on behavior is needed.

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, front-loaded sentence with no unnecessary words. It earns its place with direct clarity.

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?

For a simple tool with no parameters and no output schema, the description is minimally adequate. However, it could mention the output format (e.g., hierarchical JSON) or handle non-existent folders.

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

Parameters4/5

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

The tool has zero parameters, so the description adds no parameter-specific meaning. Per guidelines, baseline is 4 for 0 params, and schema coverage is 100% (no params).

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

Purpose5/5

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

The description 'Get the complete folder structure of the vault' uses a specific verb and resource, clearly indicating the tool's function. It distinguishes itself from sibling tools like create_folder or list_notes by focusing on retrieving the hierarchical structure.

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 guidance is provided on when to use this tool versus alternatives such as list_notes or search_notes. The agent must infer its purpose from the name alone.

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/dot-RealityTest/obsidian-codex-mcp'

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