Skip to main content
Glama

list_notes

Retrieve notes from your Obsidian vault or specific folder to organize and access your knowledge base efficiently.

Instructions

List all notes in the vault or a specific folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFolder to list notes from (omit for entire vault)
limitNoMaximum number of notes to return

Implementation Reference

  • The MCP tool "list_notes" is registered here, which calls the `listNotes` library function and formats the response.
    server.registerTool(
      "list_notes",
      {
        description: "List all notes in the vault or a specific folder",
        inputSchema: {
          folder: z
            .string()
            .optional()
            .describe("Folder to list notes from (omit for entire vault)"),
          limit: z
            .number()
            .optional()
            .default(50)
            .describe("Maximum number of notes to return"),
        },
      },
      async ({ folder, limit }) => {
        try {
          const notes = await listNotes(vaultPath, folder);
          const limited = notes.slice(0, limit);
          const totalCount = notes.length;
    
          const lines: string[] = [
            `Found ${totalCount} note(s)${folder ? ` in "${folder}"` : ""}${totalCount > limit ? ` (showing first ${limit})` : ""}:`,
            "",
            ...limited,
          ];
    
          return {
            content: [{ type: "text" as const, text: lines.join("\n") }],
          };
        } catch (err) {
          console.error("list_notes error:", err);
          return errorResult(`Error listing notes: ${err instanceof Error ? err.message : String(err)}`);
        }
      },
    );
  • The actual implementation of the note listing logic, which reads the vault directory, filters for Markdown files, and sorts them.
    export async function listNotes(
      vaultPath: string,
      folder?: string,
    ): Promise<string[]> {
      const baseDir = folder
        ? resolveVaultPath(vaultPath, folder)
        : path.resolve(vaultPath);
    
      let entries: string[];
      try {
        entries = await fs.readdir(baseDir, { recursive: true }) as unknown as string[];
      } catch (err) {
        if ((err as NodeJS.ErrnoException).code === "ENOENT") {
          return [];
        }
        throw err;
      }
    
      const notes: string[] = [];
      for (const entry of entries) {
        const normalized = entry.replace(/\\/g, "/");
        if (!normalized.endsWith(".md")) continue;
    
        const relativeFromVault = folder
          ? `${folder}/${normalized}`.replace(/\\/g, "/")
          : normalized;
    
        if (isExcluded(relativeFromVault)) continue;
        notes.push(relativeFromVault);
      }
    
      return notes.sort();
    }

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