Capture Obsidian screenshot
obsidian_dev_screenshotCapture a base64-encoded PNG screenshot of the active Obsidian window. Optionally specify a vault name to target a specific vault.
Instructions
Returns a base64-encoded PNG screenshot of the running Obsidian window.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Vault name to target. Optional — defaults to the most recently focused vault. |
Implementation Reference
- src/tools.ts:795-795 (handler)The handler for 'obsidian_dev_screenshot' calls runText('dev:screenshot', { vault }), which executes the 'dev:screenshot' command via the Obsidian CLI.
handler: async ({ vault }) => runText("dev:screenshot", { vault }), - src/tools.ts:788-796 (registration)The tool 'obsidian_dev_screenshot' is registered in the tools array with name, title, description, inputSchema, annotations, and handler.
{ name: "obsidian_dev_screenshot", title: "Capture Obsidian screenshot", description: "Returns a base64-encoded PNG screenshot of the running Obsidian window.", inputSchema: { ...VaultArg }, annotations: { readOnlyHint: true, openWorldHint: true }, handler: async ({ vault }) => runText("dev:screenshot", { vault }), }, - src/tools.ts:793-793 (schema)Input schema uses VaultArg (optional vault name). Output is base64-encoded PNG screenshot text.
inputSchema: { ...VaultArg }, - src/tools.ts:99-110 (helper)runText wraps runObsidian, returning stdout/stderr as a text result.
async function runText( command: string, opts: Parameters<typeof runObsidian>[1] = {}, ): Promise<McpToolResult> { try { const result = await runObsidian(command, opts); const text = result.stdout.trim() || result.stderr.trim() || "(no output)"; return textResult(text); } catch (err) { return errorResult(err); } } - src/exec.ts:64-90 (helper)runObsidian executes the 'obsidian' CLI with the given command (e.g., 'dev:screenshot') and returns the result.
export async function runObsidian( command: string, opts: RunOptions = {}, ): Promise<RunResult> { const bin = process.env.OBSIDIAN_CLI ?? "obsidian"; const args = buildArgs(command, opts); const cmdline = [bin, ...args].map(shellQuote).join(" "); try { const { stdout, stderr } = await exec(cmdline, { maxBuffer: 64 * 1024 * 1024, windowsHide: true, }); return { stdout, stderr, exitCode: 0, command: cmdline }; } catch (err: unknown) { const e = err as NodeJS.ErrnoException & { stdout?: string; stderr?: string; code?: number | string; }; const result: RunResult = { stdout: e.stdout ?? "", stderr: e.stderr ?? e.message ?? "", exitCode: typeof e.code === "number" ? e.code : 1, command: cmdline, }; if (e.code === "ENOENT") {