Skip to content

Conversation

@vanmarkic
Copy link

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

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

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