Skip to main content
Glama

List Bases

list_bases
Read-onlyIdempotent

Enumerate all .base files in the vault to get sorted relative paths and total count, enabling efficient management of YAML-defined database views.

Instructions

Enumerate every Obsidian Bases (.base) file in the vault. Bases are YAML-defined database views over notes (filters, properties, table/calendar/kanban views). Returns a sorted list of relative paths plus the total count. Pair with read_base or query_base.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_bases' tool. It calls listBaseFiles(vaultPath), formats the result (sorted list of relative paths and count), and returns it as text. Error handling logs failures and returns an error result.
    async () => {
      try {
        const bases = await listBaseFiles(vaultPath);
        if (bases.length === 0) return textResult("No .base files in this vault.");
        const lines = [`Found ${bases.length} Base file(s):`, "", ...bases];
        return textResult(lines.join("\n"));
      } catch (err) {
        log.error("list_bases failed", { tool: "list_bases", err: err as Error });
        return errorResult(`Error listing bases: ${sanitizeError(err)}`);
      }
    },
  • The registerBaseTools function registers the 'list_bases' tool on the McpServer with its schema (inputSchema: {}), description, and annotations (readOnlyHint, idempotentHint).
    export function registerBaseTools(server: McpServer, vaultPath: string): void {
      server.registerTool(
        "list_bases",
        {
          title: "List Bases",
          description:
            "Enumerate every Obsidian Bases (`.base`) file in the vault. Bases are YAML-defined database views over notes (filters, properties, table/calendar/kanban views). Returns a sorted list of relative paths plus the total count. Pair with read_base or query_base.",
          annotations: {
            readOnlyHint: true,
            idempotentHint: true,
            openWorldHint: false,
          },
          inputSchema: {},
        },
        async () => {
          try {
            const bases = await listBaseFiles(vaultPath);
            if (bases.length === 0) return textResult("No .base files in this vault.");
            const lines = [`Found ${bases.length} Base file(s):`, "", ...bases];
            return textResult(lines.join("\n"));
          } catch (err) {
            log.error("list_bases failed", { tool: "list_bases", err: err as Error });
            return errorResult(`Error listing bases: ${sanitizeError(err)}`);
          }
        },
      );
  • The input schema for 'list_bases' – an empty object ({}), meaning no arguments are required.
    "list_bases",
    {
      title: "List Bases",
      description:
        "Enumerate every Obsidian Bases (`.base`) file in the vault. Bases are YAML-defined database views over notes (filters, properties, table/calendar/kanban views). Returns a sorted list of relative paths plus the total count. Pair with read_base or query_base.",
      annotations: {
        readOnlyHint: true,
        idempotentHint: true,
        openWorldHint: false,
      },
  • The listBaseFiles helper function walks the vault directory tree for .base files using walkVault(), then filters out excluded directories and returns a sorted array of relative paths.
    export async function listBaseFiles(
      vaultPath: string,
    ): Promise<string[]> {
      const entries = await walkVault(await getRealVaultRoot(vaultPath), [".base"]);
      const out: string[] = [];
      for (const rel of entries) {
        if (isExcluded(rel)) continue;
        out.push(rel);
      }
      return out.sort();
    }
  • The walkVault helper function recursively walks the vault directory, filtering by file extension (here '.base') and excluding .obsidian/.trash/.git directories.
    async function walkVault(
      baseDir: string,
      extensions: string[],
    ): Promise<string[]> {
      const results: string[] = [];
      const exts = extensions.map((e) => e.toLowerCase());
    
      async function walk(dir: string, relPrefix: string): Promise<void> {
        let entries: import("fs").Dirent[];
        try {
          entries = await fs.readdir(dir, { withFileTypes: true });
        } catch (err) {
          if ((err as NodeJS.ErrnoException).code === "ENOENT") return;
          throw err;
        }
        for (const entry of entries) {
          const name = entry.name;
          if (entry.isDirectory()) {
            // Prune excluded directory names at ANY depth. Obsidian's own
            // subfolders aside, nested `.git`/`.obsidian`/`.trash` directories
            // should never be surfaced to clients.
            if (EXCLUDED_SET.has(name.toLowerCase())) continue;
            const nextPrefix = relPrefix === "" ? name : `${relPrefix}/${name}`;
            await walk(path.join(dir, name), nextPrefix);
          } else if (entry.isFile()) {
            const lower = name.toLowerCase();
            if (!exts.some((ext) => lower.endsWith(ext))) continue;
            const relPath = relPrefix === "" ? name : `${relPrefix}/${name}`;
            results.push(relPath);
          }
        }
      }
    
      await walk(baseDir, "");
      return results;
    }
Behavior4/5

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

Annotations already indicate read-only and idempotent behavior; the description adds value by specifying the return format (sorted list of relative paths plus total count) and the nature of base files (YAML-defined database views), which goes beyond the annotations.

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 two sentences, front-loaded with the action, efficient, with no unnecessary words.

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

Completeness5/5

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

Given the tool's simplicity (0 parameters, no output schema), the description fully explains its purpose, output, and suggests next steps, making it complete.

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 no parameters, and schema coverage is 100% trivially. The description does not need to add parameter info; baseline 4 is appropriate.

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 clearly states it enumerates every Obsidian Bases (.base) file in the vault, and distinguishes from siblings by mentioning pairing with read_base or query_base.

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

Usage Guidelines5/5

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

It explicitly says when to use this tool (to list all base files) and suggests pairing with read_base or query_base for further actions, providing clear usage guidance.

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

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