get_vault_stats
Retrieve comprehensive statistics about your Obsidian vault to analyze content structure, track note counts, and monitor vault health metrics.
Instructions
Get statistics about the vault
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_vault_stats"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/obsidian_mcp/server.py:446-474 (handler)MCP tool registration and handler function for 'get_vault_stats'. Retrieves vault statistics using ObsidianVault.get_vault_stats() and formats them for output.
@mcp.tool(name="get_vault_stats", description="Get statistics about the vault") def get_vault_stats() -> str: """ Get statistics about the vault. Returns: Formatted vault statistics """ context = _get_context() try: stats = context.vault.get_vault_stats() output = "# Vault Statistics\n\n" output += f"**Total Notes:** {stats['total_notes']}\n" output += f"**Total Tags:** {stats['total_tags']}\n" output += f"**Total Size:** {stats['total_size_bytes']:,} bytes\n\n" if stats["unique_tags"]: output += "**Top Tags:**\n" for tag in stats["unique_tags"][:20]: output += f"- #{tag}\n" return output except Exception as e: logger.exception("Error getting vault stats") return f"Error getting vault stats: {e}" - src/obsidian_mcp/vault.py:443-460 (helper)Helper method in ObsidianVault class that computes the core vault statistics: total notes, total tags count, total size in bytes, and list of unique tags.
def get_vault_stats(self) -> dict[str, Any]: """ Get statistics about the vault. Returns: Dict with vault statistics """ notes = self.list_notes(limit=100000, include_tags=True) tags = self.get_all_tags() total_size = sum(note.size for note in notes) return { "total_notes": len(notes), "total_tags": len(tags), "total_size_bytes": total_size, "unique_tags": sorted(tags.keys()), }