Skip to content

feat: Add Obsidian command execution support via MCP tools (#29)#47

Open
vanmarkic wants to merge 2 commits intojacksteamdev:mainfrom
vanmarkic:claude/fix-issue-29-command-execution-01DypPdPvjF9qDyRDG1CAob5
Open

feat: Add Obsidian command execution support via MCP tools (#29)#47
vanmarkic wants to merge 2 commits intojacksteamdev:mainfrom
vanmarkic:claude/fix-issue-29-command-execution-01DypPdPvjF9qDyRDG1CAob5

Conversation

@vanmarkic
Copy link
Copy Markdown

Summary

  • Adds MCP tools to execute Obsidian commands programmatically
  • Includes comprehensive test coverage for command execution functionality
  • Enables automation and integration with external tools

Changes

  • Implemented list_commands tool to retrieve available Obsidian commands
  • Implemented execute_command tool to run commands by ID
  • Added 275 lines of tests covering various command execution scenarios
  • Proper error handling for invalid commands and execution failures

Related Issue

Addresses feature request #29

🤖 Generated with Claude Code

…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
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 15, 2025

Deploy Preview for superb-starlight-b5acb5 canceled.

Name Link
🔨 Latest commit 4fbb677
🔍 Latest deploy log https://app.netlify.com/projects/superb-starlight-b5acb5/deploys/6918c16669b7f00008a6af2a

istefox added a commit to istefox/obsidian-mcp-tools 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants