feat: Add Obsidian command execution support via MCP tools (#29)#47
Open
vanmarkic wants to merge 2 commits intojacksteamdev:mainfrom
Open
Conversation
…dev#29) Implemented two new MCP tools to expose Obsidian's command palette functionality: **New Tools:** 1. `list_obsidian_commands` - Lists all available Obsidian commands with their IDs and names 2. `execute_obsidian_command` - Executes a command by its ID **Use Cases:** - Automated daily note creation respecting plugin configurations - External triggering of plugin-specific workflows - Command palette automation through MCP integration - Integration with AI assistants for workflow automation **Implementation:** - Leverages existing Local REST API `/commands/` endpoints - Uses proper schema validation with empty object for no-arg tools - Includes descriptive examples in tool descriptions - URL-encodes command IDs to handle special characters safely **Example commands that can be executed:** - `daily-notes` - Create today's daily note - `editor:toggle-bold` - Toggle bold formatting - `workspace:split-vertical` - Split workspace vertically - Plugin-specific commands from installed plugins This allows MCP clients like Claude Desktop to discover and execute any Obsidian command, enabling powerful automation while respecting plugin settings and templates. Fixes jacksteamdev#29
- Test list_obsidian_commands schema structure - Test execute_obsidian_command schema with commandId argument - Test command ID validation and type checking - Test URL encoding for command IDs with special characters - Test encoding of colons, slashes, spaces in command IDs - Test ApiCommandsResponse and ApiCommand schema structures - Test integration between listing and executing commands - Verify common Obsidian command patterns are properly encoded
✅ Deploy Preview for superb-starlight-b5acb5 canceled.
|
istefox
added a commit
to istefox/obsidian-mcp-connector
that referenced
this pull request
Apr 11, 2026
The Open issues, Testing, Gotchas, and Suggested next steps sections were frozen at 2026-04-11 and did not reflect any of the work that has since landed on myfork/main. This commit brings CLAUDE.md back in sync with the actual working tree. Adds a new "Fork status" sub-section near the top explaining that active work happens on the istefox/obsidian-mcp-tools fork and how to read the fork markers (✅ + commit SHA) used further down. Gotchas: annotates the four previously-upstream-only bug notes that have now been fixed locally with [FORK: FIXED in <sha>] prefixes (patch_vault_file nested headings, patch_vault_file non-ASCII headings, hardcoded port 27124, Local REST API v3.4.x schema). Adds three new gotcha entries for production bugs the installer test suite uncovered during this session: resolveSymlinks ENOENT fallback returning a relative path, uninstallServer throwing on ENOENT during rmdir, and uninstallServer config cleanup being macOS-only — all three now fixed in the fork with commit SHAs recorded. Testing & CI: rewritten with current numbers (88 server + 66 plugin = 154 pass) and documentation of the new plugin test infrastructure that was missing from the original snapshot: bunfig.toml, the test-setup.ts module mock for "obsidian", .env.test for the build-time macro in install.ts, the spyOn(os, "homedir") pattern for HOME-based path tests, and the real-shell-script approach used by status.integration.test.ts. Project status — Static analysis findings: the "test coverage is thin" note is updated with the new counts; the "dual validators (zod + arktype)" note is marked [FORK: FIXED in 7e95366]. Open issues & PRs snapshot: adds a legend for the ✅ marker and annotates every cluster header (A through F) with the corresponding fork commit SHA. Cluster G's table gains a "Fork status" column showing 5 of 9 items closed and the remaining 4 (issue jacksteamdev#28, jacksteamdev#26, jacksteamdev#29 and PR jacksteamdev#47) still open. Suggested next steps: the 12-item roadmap is rewritten — steps 2-7 and 9 are marked ✅ with SHAs; step 1 (maintainership stance), step 8 (SDK upgrade), and steps 10-12 (cline_docs, branch pruning, prompt docs) remain open with updated rationale. Adds a "Still pending from Cluster G" subsection for the four remaining feature requests, and notes that command execution (jacksteamdev#29 / PR jacksteamdev#47) is gated on a security design review. No code changes. bun run check and plugin test suite (66 pass) were re-run as a sanity check and stay green.
istefox
added a commit
to istefox/obsidian-mcp-connector
that referenced
this pull request
Apr 11, 2026
…acksteamdev#29) Delivers the security design review called out in the CLAUDE.md "Still pending from Cluster G" list. No code changes — this commit only adds the reference document and wires it into CLAUDE.md so the next session can pick up implementation without reconstructing the threat model. The doc (docs/design/issue-29-command-execution.md, ~420 lines) covers: - Problem statement, why the naive "pass-through" approach fails, and the threat model (MCP client prompt injection, third-party plugins inside the trust boundary, click-through fatigue). - Six policy options evaluated (static whitelist, static denylist, per-command allowlist, per-category allowlist, always-confirm, hybrid). Four are explicitly rejected with reasoning. - Recommendation: **Option F (hybrid)** — per-invocation "Allow once / always / deny" prompt with a persistent user-built allowlist. Same mental model as browser permission prompts. - MCP tool surface: `list_obsidian_commands` (read-only, no gate) and `execute_obsidian_command` (always gated). Full TypeScript pseudocode for both handlers. - Plugin-side design: new `/mcp-tools/command-permission/:id/` long-polling HTTP endpoint that shows a Svelte modal and waits for the user's decision (max 30s), plus a new `features/command-permissions/` feature module with settings UI, audit log, and rate limiting. - Settings augmentation shape (`commandPermissions?: { allowlist, killswitch, requireConfirmationEveryTime }`), audit log entry schema, and the soft/hard rate limit numbers (30/min soft, 100/min hard — read-only list tool not limited). - Destructive-command heuristic: regex nudge in the modal that tints the UI red and disables "Allow always" when the command id matches /delete|remove|uninstall|trash|clean|purge|drop| reset|clear|wipe/. Explicitly framed as a nudge, not a gate. - Three-phase implementation roadmap: MVP (allowlist only, no modal) → UX polish (modal + long-poll + audit viewer) → hardening (tests, rate limits, docs). - Five open questions flagged for the implementer to answer before starting Fase 1: should the list tool also be gated by the master toggle, what happens when the master toggle is off, should there be a "deny always" option, should allowlist entries be by id or by (id, name) tuple, and whether to record MCP client identity in the audit log. Also adds a pointer from CLAUDE.md's in-repo docs section so the design doc is discoverable alongside .clinerules and the existing feature specs. The fork explicitly diverges from upstream PR jacksteamdev#47 — the upstream PR remains open and unreviewed, and the design chosen here prioritizes a user-consent model over code compatibility with the upstream proposal. Anyone cherry-picking PR jacksteamdev#47 should re-read the design doc first and treat the hybrid model as the contract. Zero code changes. No test count impact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
list_commandstool to retrieve available Obsidian commandsexecute_commandtool to run commands by IDRelated Issue
Addresses feature request #29
🤖 Generated with Claude Code