obsidian_list_commands
Retrieves all available commands from Obsidian's command palette using the local REST API. Provides programmatic inspection of plugin registered commands.
Instructions
List Obsidian command-palette commands through Local REST API.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools.ts:1257-1266 (registration)Registration of the obsidian_list_commands tool via the local 'tool()' helper. Uses the Obsidian Local REST API to list command-palette commands.
tool( "obsidian_list_commands", "List Obsidian command-palette commands through Local REST API.", {}, async () => { if (!config.enableCommands) throw new Error("Set OBSIDIAN_ENABLE_COMMANDS=1 to expose command-palette tooling."); return obsidianRestRequest(config, { path: "/commands/" }); }, { readOnlyHint: true }, ); - src/tools.ts:1261-1264 (handler)Handler for obsidian_list_commands: checks OBSIDIAN_ENABLE_COMMANDS config, then proxies to obsidianRestRequest with path '/commands/'.
async () => { if (!config.enableCommands) throw new Error("Set OBSIDIAN_ENABLE_COMMANDS=1 to expose command-palette tooling."); return obsidianRestRequest(config, { path: "/commands/" }); }, - src/tools.ts:1258-1260 (schema)Schema for obsidian_list_commands: no parameters (empty object). Tool description: 'List Obsidian command-palette commands through Local REST API.'
"obsidian_list_commands", "List Obsidian command-palette commands through Local REST API.", {}, - src/rest.ts:11-56 (helper)obsidianRestRequest helper function that makes HTTP requests to the Obsidian Local REST API. Used by the handler to call GET /commands/.
export async function obsidianRestRequest(config: ObsidianMcpConfig, options: RestRequestOptions): Promise<{ status: number; ok: boolean; contentType: string; body: unknown; }> { if (!config.restApiKey) throw new Error("OBSIDIAN_API_KEY is not configured"); if (config.restInsecureTls) process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; const url = new URL(options.path.replace(/^\/+/, ""), `${config.restUrl.replace(/\/+$/, "")}/`); const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? 15000); try { const headers: Record<string, string> = { Authorization: `Bearer ${config.restApiKey}`, }; let body: string | undefined; if (options.body !== undefined) { if (typeof options.body === "string") { body = options.body; headers["Content-Type"] = options.contentType ?? "text/markdown"; } else { body = JSON.stringify(options.body); headers["Content-Type"] = options.contentType ?? "application/json"; } } const response = await fetch(url, { method: options.method ?? "GET", headers, body, signal: controller.signal, }); const contentType = response.headers.get("content-type") ?? ""; const text = await response.text(); let parsed: unknown = text; if (contentType.includes("application/json")) { try { parsed = JSON.parse(text); } catch { parsed = text; } } return { status: response.status, ok: response.ok, contentType, body: parsed }; } finally { clearTimeout(timeout); } } - src/config.ts:21-21 (helper)The 'enableCommands' config flag (OBSIDIAN_ENABLE_COMMANDS) that gates access to obsidian_list_commands.
enableCommands: boolean;