Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_vault_themes

Read-only

Extract key terms from vault files using TF-IDF, then cluster them to map underlying themes.

Instructions

Map vault themes with TF-IDF-style term extraction and lightweight clustering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
limitNo
minFilesNo

Implementation Reference

  • src/tools.ts:857-867 (registration)
    Tool registration for 'obsidian_vault_themes'. Defines the tool name, description, Zod schema (vault, limit, minFiles), and calls vaultThemes() from intelligence.ts. Annotated as readOnlyHint.
    tool(
      "obsidian_vault_themes",
      "Map vault themes with TF-IDF-style term extraction and lightweight clustering.",
      {
        vault: vaultArg,
        limit: z.number().int().min(1).max(100).optional().default(20),
        minFiles: z.number().int().min(1).max(20).optional().default(2),
      },
      async (args) => vaultThemes(await loadNotes(vaults, args.vault), args.limit, args.minFiles),
      { readOnlyHint: true },
    );
  • Input schema for 'obsidian_vault_themes': vault (optional string), limit (1-100, default 20), minFiles (1-20, default 2).
    tool(
      "obsidian_vault_themes",
      "Map vault themes with TF-IDF-style term extraction and lightweight clustering.",
      {
        vault: vaultArg,
        limit: z.number().int().min(1).max(100).optional().default(20),
        minFiles: z.number().int().min(1).max(20).optional().default(2),
      },
      async (args) => vaultThemes(await loadNotes(vaults, args.vault), args.limit, args.minFiles),
      { readOnlyHint: true },
    );
  • Core handler function vaultThemes(). Takes NoteRecord[], limit, and minFiles. Extracts top TF-IDF terms per note, clusters notes with Jaccard similarity >= 0.25, filters by minFiles, sorts by file count/coherence, and returns themes + orphanCandidates.
    export function vaultThemes(notes: NoteRecord[], limit = 20, minFiles = 2): { themes: Theme[]; orphanCandidates: string[] } {
      const topTermsByNote = notes.map((note) => ({
        note,
        terms: topTerms(note, 12),
      }));
      const themes: Theme[] = [];
      for (const item of topTermsByNote) {
        if (item.terms.length === 0) continue;
        let best: { theme: Theme; score: number } | null = null;
        for (const theme of themes) {
          const overlap = jaccard(new Set(item.terms.slice(0, 8)), new Set(theme.keyTerms.slice(0, 8)));
          if (!best || overlap > best.score) best = { theme, score: overlap };
        }
        if (best && best.score >= 0.25) {
          best.theme.files.push(item.note.path);
          best.theme.keyTerms = mergeTopTerms(best.theme.keyTerms, item.terms);
          best.theme.folders = uniqueFolders(best.theme.files);
          best.theme.crossFolder = best.theme.folders.length > 1;
          best.theme.coherence = Number(((best.theme.coherence + best.score) / 2).toFixed(3));
        } else {
          const files = [item.note.path];
          themes.push({
            id: `theme-${themes.length + 1}`,
            label: labelFromTerms(item.terms),
            keyTerms: item.terms,
            files,
            folders: uniqueFolders(files),
            coherence: 1,
            crossFolder: false,
          });
        }
      }
      const filtered = themes
        .filter((theme) => theme.files.length >= minFiles)
        .map((theme, i) => ({ ...theme, id: `theme-${i + 1}`, label: labelFromTerms(theme.keyTerms) }))
        .sort((a, b) => b.files.length - a.files.length || b.coherence - a.coherence)
        .slice(0, limit);
      const themed = new Set(filtered.flatMap((theme) => theme.files));
      return {
        themes: filtered,
        orphanCandidates: notes.filter((note) => !themed.has(note.path)).map((note) => note.path).slice(0, 100),
      };
    }
  • Type definition for Theme: id, label, keyTerms, files, folders, coherence, crossFolder. Used as the return type of vaultThemes().
    export type Theme = {
      id: string;
      label: string;
      keyTerms: string[];
      files: string[];
      folders: string[];
      coherence: number;
      crossFolder: boolean;
    };
  • Helper functions used by vaultThemes: labelFromTerms() (creates label from top 3 key terms), safeTitle() (Title Case formatting), uniqueFolders() (extracts unique dirnames), jaccard() (set similarity), mergeTopTerms() (union of term arrays), topTerms() (extract top weighted terms from a note).
    function labelFromTerms(terms: string[]): string {
      return safeTitle(terms.slice(0, 3).join(" "));
    }
    
    function safeTitle(text: string): string {
      return text
        .split(/\s+/)
        .filter(Boolean)
        .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
        .join(" ");
    }
Behavior2/5

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

Annotations already declare readOnly and non-destructive; description adds only the TF-IDF and clustering method, with no additional behavioral context like output format or side effects.

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

Conciseness3/5

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

Single sentence, concise but lacks structure and important details; could be expanded to cover parameters and usage.

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

Completeness2/5

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

No output schema, and description does not hint at return value; for a tool performing TF-IDF and clustering, more context is needed for proper use.

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

Parameters1/5

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

Schema description coverage is 33% (only 'vault' has a description); tool description provides no parameter details, leaving limit and minFiles unexplained.

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?

Description clearly states the tool maps vault themes using TF-IDF-style term extraction and lightweight clustering, distinguishing it from sibling tools like search or graph stats.

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?

No explicit guidance on when to use vs alternatives, but the unique purpose implies thematic analysis; could be improved with direct comparisons.

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

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