obsidian_open_in_ui
Open a note in the Obsidian UI by specifying its vault-relative path. Requires the OBSIDIAN_ENABLE_UI_OPEN environment variable set to 1.
Instructions
Open a note in the Obsidian UI via obsidian:// URI. Execution requires OBSIDIAN_ENABLE_UI_OPEN=1.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Optional configured vault name. Defaults to the server default vault. | |
| path | Yes | Vault-relative path. Absolute paths and traversal are rejected. | |
| execute | No |
Implementation Reference
- src/tools.ts:1307-1319 (handler)The handler for obsidian_open_in_ui tool. It builds an obsidian://open URI for the given vault and note path. If execute=false it returns the URI without running it. If execute=true and OBSIDIAN_ENABLE_UI_OPEN is set, it calls `open` (macOS command) to open the URI in the Obsidian UI.
tool( "obsidian_open_in_ui", "Open a note in the Obsidian UI via obsidian:// URI. Execution requires OBSIDIAN_ENABLE_UI_OPEN=1.", { vault: vaultArg, path: pathArg, execute: z.boolean().optional().default(false) }, async (args) => { const vault = vaults.getVault(args.vault); const uri = `obsidian://open?vault=${encodeURIComponent(vault.name)}&file=${encodeURIComponent(vaults.notePath(args.path))}`; if (!args.execute) return { uri, executed: false }; if (!config.enableUiOpen) throw new Error("Set OBSIDIAN_ENABLE_UI_OPEN=1 to allow this tool to open the Obsidian UI."); await execFileAsync("open", [uri], { timeout: 5000 }); return { uri, executed: true }; }, ); - src/tools.ts:1308-1310 (schema)Input schema for obsidian_open_in_ui: vault (optional), path (required vault-relative path), and execute (optional boolean, defaults to false).
"obsidian_open_in_ui", "Open a note in the Obsidian UI via obsidian:// URI. Execution requires OBSIDIAN_ENABLE_UI_OPEN=1.", { vault: vaultArg, path: pathArg, execute: z.boolean().optional().default(false) }, - src/tools.ts:1307-1319 (registration)The tool is registered inside the registerObsidianTools function (line 38) using the local `tool()` helper which wraps server.tool() on the McpServer.
tool( "obsidian_open_in_ui", "Open a note in the Obsidian UI via obsidian:// URI. Execution requires OBSIDIAN_ENABLE_UI_OPEN=1.", { vault: vaultArg, path: pathArg, execute: z.boolean().optional().default(false) }, async (args) => { const vault = vaults.getVault(args.vault); const uri = `obsidian://open?vault=${encodeURIComponent(vault.name)}&file=${encodeURIComponent(vaults.notePath(args.path))}`; if (!args.execute) return { uri, executed: false }; if (!config.enableUiOpen) throw new Error("Set OBSIDIAN_ENABLE_UI_OPEN=1 to allow this tool to open the Obsidian UI."); await execFileAsync("open", [uri], { timeout: 5000 }); return { uri, executed: true }; }, ); - src/config.ts:22-22 (helper)The enableUiOpen config flag (OBSIDIAN_ENABLE_UI_OPEN env var) that gates the execute behavior of obsidian_open_in_ui.
enableUiOpen: boolean; - src/tools.ts:1296-1305 (helper)The related obsidian_open_uri tool which builds the same obsidian://open URI but never executes it (read-only hint).
"obsidian_open_uri", "Build an obsidian://open URI for a note. This does not execute OS commands.", { vault: vaultArg, path: pathArg }, (args) => { const vault = vaults.getVault(args.vault); const file = encodeURIComponent(vaults.notePath(args.path)); return { uri: `obsidian://open?vault=${encodeURIComponent(vault.name)}&file=${file}` }; }, { readOnlyHint: true }, );