list_canvas_files
Retrieve all canvas files from your Obsidian vault to organize and access visual content for knowledge management.
Instructions
List all canvas files in vault
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | Yes | Vault name |
Implementation Reference
- src/services/CanvasService.ts:363-378 (handler)The primary handler function that implements the tool logic by using glob to find all '*.canvas' files in the vault and returns their relative paths or an error.async listCanvasFiles(vaultPath: string): Promise<VaultOperationResult<string[]>> { try { const { glob } = await import('glob'); const pattern = path.join(vaultPath, '**/*.canvas'); const files = await glob(pattern, { ignore: '**/node_modules/**' }); const relativePaths = files.map(f => path.relative(vaultPath, f)); return { success: true, data: relativePaths }; } catch (error) { return { success: false, error: `Failed to list canvas files: ${error instanceof Error ? error.message : String(error)}` }; } }
- src/index.ts:277-287 (schema)The tool schema definition in the list of available tools, specifying the name, description, and input schema that requires a 'vault' parameter.{ name: 'list_canvas_files', description: 'List all canvas files in vault', inputSchema: { type: 'object', properties: { vault: { type: 'string', description: 'Vault name' }, }, required: ['vault'], }, },
- src/index.ts:733-743 (registration)The tool registration and dispatch logic in the main switch statement for handling CallToolRequestSchema, which retrieves the vault connector and calls the CanvasService handler.case 'list_canvas_files': { const connector = this.connectors.get(args?.vault as string); if (!connector || !connector.vaultPath) { throw new Error(`Vault "${args?.vault}" not found or not a local vault`); } const result = await this.canvasService.listCanvasFiles(connector.vaultPath); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }