get_vault_info
Retrieve details about an Obsidian vault, including its structure and metadata, by providing the vault's file path.
Instructions
Get information about a specific vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault_path | Yes | Path to the Obsidian vault |
Implementation Reference
- src/tools/vault.ts:16-30 (handler)The main handler function that executes the tool logic: fetches vault stats from VaultManager and returns formatted information including note count, size, etc.export async function handleGetVaultInfo( vaultManager: VaultManager, vaultPath: string ) { const stats = await vaultManager.getVaultStats(vaultPath); return { path: stats.path, name: stats.name, noteCount: stats.noteCount, totalSize: stats.size, lastModified: stats.lastModified, sizeFormatted: formatBytes(stats.size || 0), }; }
- src/index.ts:47-56 (schema)Input schema defining the required 'vault_path' parameter for the tool.inputSchema: { type: 'object', properties: { vault_path: { type: 'string', description: 'Path to the Obsidian vault', }, }, required: ['vault_path'], },
- src/index.ts:44-57 (registration)Tool definition registered in the TOOLS array for the list_tools MCP request.{ name: 'get_vault_info', description: 'Get information about a specific vault', inputSchema: { type: 'object', properties: { vault_path: { type: 'string', description: 'Path to the Obsidian vault', }, }, required: ['vault_path'], }, },
- src/index.ts:176-181 (registration)Dispatch logic in the call_tool handler that invokes the get_vault_info tool implementation.case 'get_vault_info': if (!args || typeof args !== 'object' || !('vault_path' in args)) { throw new McpError(ErrorCode.InvalidParams, 'Missing vault_path'); } result = await handleGetVaultInfo(vaultManager, args.vault_path as string); break;
- src/tools/vault.ts:32-40 (helper)Helper function used by the handler to format the total size of the vault into human-readable bytes.function formatBytes(bytes: number): string { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }