Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_execute_commands

Execute multiple Obsidian commands sequentially to automate workflows, such as note operations and interface actions, through the Advanced Obsidian MCP Server.

Instructions

Execute one or more commands in obsidian interface, in order. For commands used on specific notes, make sure to open a note first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandsYesList of commands to execute

Implementation Reference

  • The run_tool method in ExecuteCommandsToolHandler that implements the core logic of the 'obsidian_execute_commands' tool: executes each command in the input list using api.execute_command and returns success/error messages.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]: commands = args.get("commands") if not commands: raise ValueError("One or more commands are required") results = [] success = True for command in commands: try: api.execute_command(command) results.append(f"Command '{command}' executed successfully") except Exception as e: success = False results.append(f"Failed to execute command '{command}': {str(e)}") if success: return [ TextContent( type="text", text="All commands executed successfully!" ) ] else: return [ TextContent( type="text", text="\n".join(results) ) ]
  • The inputSchema defined in get_tool_description of ExecuteCommandsToolHandler for validating tool arguments: requires an array of command strings.
    return Tool( name=self.name, description="Execute one or more commands in obsidian interface, *in order*. For commands used on specific notes, make sure to open a note first.", inputSchema={ "type": "object", "properties": { "commands": { "type": "array", "items": { "type": "string", "description": "Command to execute" }, "description": "List of commands to execute" }, }, "required": ["commands"] } )
  • TOOL_MAPPING dictionary that associates the tool name 'obsidian_execute_commands' (imported as tools.TOOL_EXECUTE_COMMANDS) with its handler class for registration.
    TOOL_MAPPING = { tools.TOOL_LIST_FILES_IN_DIR: tools.ListFilesInDirToolHandler, tools.TOOL_SIMPLE_SEARCH: tools.SearchToolHandler, tools.TOOL_PATCH_CONTENT: tools.PatchContentToolHandler, tools.TOOL_PUT_CONTENT: tools.PutContentToolHandler, tools.TOOL_APPEND_CONTENT: tools.AppendContentToolHandler, tools.TOOL_DELETE_FILE: tools.DeleteFileToolHandler, tools.TOOL_COMPLEX_SEARCH: tools.ComplexSearchToolHandler, tools.TOOL_BATCH_GET_FILES: tools.BatchGetFilesToolHandler, tools.TOOL_PERIODIC_NOTES: tools.PeriodicNotesToolHandler, tools.TOOL_RECENT_PERIODIC_NOTES: tools.RecentPeriodicNotesToolHandler, tools.TOOL_RECENT_CHANGES: tools.RecentChangesToolHandler, tools.TOOL_UNDERSTAND_VAULT: tools.UnderstandVaultToolHandler, tools.TOOL_GET_ACTIVE_NOTE: tools.GetActiveNoteToolHandler, tools.TOOL_OPEN_FILES: tools.OpenFilesToolHandler, tools.TOOL_LIST_COMMANDS: tools.ListCommandsToolHandler, tools.TOOL_EXECUTE_COMMANDS: tools.ExecuteCommandsToolHandler, }
  • register_tools function that instantiates handlers from TOOL_MAPPING (conditionally based on INCLUDE_TOOLS env var) and adds them to tool_handlers dictionary used by MCP server endpoints.
    def register_tools(): """Register the selected tools with the server.""" tools_to_include = parse_include_tools() registered_count = 0 for tool_name in tools_to_include: if tool_name in TOOL_MAPPING: handler_class = TOOL_MAPPING[tool_name] handler_instance = handler_class() add_tool_handler(handler_instance) registered_count += 1 logger.debug(f"Registered tool: {tool_name}") logger.info(f"Successfully registered {registered_count} tools")
  • Constant defining the tool name string 'obsidian_execute_commands', used in handler __init__ and server registration mapping.
    TOOL_EXECUTE_COMMANDS = "obsidian_execute_commands"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ToKiDoO/mcp-obsidian-advanced'

If you have feedback or need assistance with the MCP directory API, please join our Discord server