Skip to main content
Glama
bazylhorsey
by bazylhorsey

get_vault_stats

Retrieve statistics about an Obsidian vault to analyze content metrics and vault structure for knowledge management insights.

Instructions

Get statistics about a vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultYesVault name

Implementation Reference

  • src/index.ts:133-143 (registration)
    Tool registration in listTools handler, including name, description, and input schema for get_vault_stats
    {
      name: 'get_vault_stats',
      description: 'Get statistics about a vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
        },
        required: ['vault'],
      },
    },
  • Dispatch handler in callToolRequestSchema that retrieves the connector for the vault and calls connector.getStats()
    case 'get_vault_stats': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector) {
        throw new Error(`Vault "${args?.vault}" not found`);
      }
      const result = await connector.getStats();
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Core implementation of getStats() in LocalConnector: computes vault statistics by iterating over all notes, counting words, links, tags, and tracking last modified date
    async getStats(): Promise<VaultOperationResult<VaultStats>> {
      try {
        const allNotes = await this.getAllNotes();
        if (!allNotes.success || !allNotes.data) {
          return { success: false, error: 'Failed to get notes for stats' };
        }
    
        const notes = allNotes.data;
        const tags = new Map<string, number>();
        let totalWords = 0;
        let totalLinks = 0;
        let lastModified: Date | undefined;
    
        for (const note of notes) {
          totalWords += countWords(note.content);
    
          if (note.links) {
            totalLinks += note.links.length;
          }
    
          if (note.tags) {
            for (const tag of note.tags) {
              tags.set(tag, (tags.get(tag) || 0) + 1);
            }
          }
    
          if (note.modifiedAt && (!lastModified || note.modifiedAt > lastModified)) {
            lastModified = note.modifiedAt;
          }
        }
    
        const stats: VaultStats = {
          noteCount: notes.length,
          totalWords,
          totalLinks,
          tags,
          lastModified
        };
    
        return { success: true, data: stats };
      } catch (error) {
        return {
          success: false,
          error: `Failed to get stats: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
  • Implementation of getStats() in RemoteConnector: prefers server-side /stats endpoint, falls back to client-side calculation similar to LocalConnector (no lastModified)
    async getStats(): Promise<VaultOperationResult<VaultStats>> {
      try {
        // Try server-side stats first
        try {
          const response = await this.client.get('/stats');
          if (response.data) {
            return { success: true, data: response.data };
          }
        } catch {
          // Fall back to client-side calculation
        }
    
        // Client-side stats calculation
        const allNotes = await this.getAllNotes();
        if (!allNotes.success || !allNotes.data) {
          return { success: false, error: 'Failed to get notes for stats' };
        }
    
        const notes = allNotes.data;
        const tags = new Map<string, number>();
        let totalWords = 0;
        let totalLinks = 0;
    
        for (const note of notes) {
          totalWords += countWords(note.content);
    
          if (note.links) {
            totalLinks += note.links.length;
          }
    
          if (note.tags) {
            for (const tag of note.tags) {
              tags.set(tag, (tags.get(tag) || 0) + 1);
            }
          }
        }
    
        const stats: VaultStats = {
          noteCount: notes.length,
          totalWords,
          totalLinks,
          tags
        };
    
        return { success: true, data: stats };
      } catch (error) {
        return {
          success: false,
          error: `Failed to get stats: ${error instanceof Error ? error.message : String(error)}`
        };
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Get statistics') but doesn't clarify what types of statistics are returned, whether this is a read-only operation, if it requires specific permissions, or any rate limits. This leaves significant gaps in understanding the tool's behavior.

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's front-loaded and wastes no space, making it easy for an agent to parse quickly.

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?

For a tool with no annotations and no output schema, the description is incomplete. It doesn't explain what statistics are returned (e.g., file counts, sizes, or metadata), leaving the agent uncertain about the output. Given the complexity of potentially varied statistics and the lack of structured data, more detail is needed to be fully helpful.

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?

The input schema has 100% description coverage, with the parameter 'vault' documented as 'Vault name'. The description adds no additional semantic context beyond this, such as examples or constraints on vault names. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema handles the 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 ('Get') and resource ('statistics about a vault'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_note_metadata' or 'get_knowledge_graph' that also retrieve information, leaving room for ambiguity about when to use this specific tool.

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. With siblings like 'get_note_metadata' and 'get_knowledge_graph' that might overlap in retrieving vault-related data, the description lacks context about specific use cases or exclusions, leaving the agent to guess based on the tool 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/bazylhorsey/obsidian-mcp-server'

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