Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_append_to_file

Add content to new or existing files in your Obsidian vault to maintain notes, logs, or documentation without manual editing.

Instructions

Append content to a new or existing file in the vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the file (relative to vault root)
contentYesContent to append to the file

Implementation Reference

  • The run_tool method of AppendContentToolHandler that executes the tool: validates input arguments, calls api.append_content to perform the append operation, and returns a success message.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if "filepath" not in args or "content" not in args:
            raise RuntimeError("filepath and content arguments required")
    
        api.append_content(args.get("filepath", ""), args["content"])
    
        return [
            TextContent(
                type="text",
                text=f"Successfully appended content to {args['filepath']}"
            )
        ]
  • Input schema definition for the obsidian_append_to_file tool, specifying filepath (string, path format) and content (string) as required parameters.
        inputSchema={
            "type": "object",
            "properties": {
                "filepath": {
                    "type": "string",
                    "description": "Path to the file (relative to vault root)",
                    "format": "path"
                },
                "content": {
                    "type": "string",
                    "description": "Content to append to the file"
                }
            },
            "required": ["filepath", "content"]
        }
    )
  • TOOL_MAPPING dictionary registering the tool name TOOL_APPEND_CONTENT ('obsidian_append_to_file') to its AppendContentToolHandler class.
    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,
    }
  • The Obsidian API helper method that sends a POST request to the Obsidian REST API endpoint to append the given content to the specified file path in the vault.
    def append_content(self, filepath: str, content: str) -> Any:
        url = f"{self.get_base_url()}/vault/{filepath}"
        
        def call_fn():
            response = requests.post(
                url, 
                headers=self._get_headers() | {'Content-Type': 'text/markdown'}, 
                data=content,
                verify=self.verify_ssl,
                timeout=self.timeout
            )
            response.raise_for_status()
            return None
    
        return self._safe_call(call_fn)
  • The register_tools function that instantiates handler classes from TOOL_MAPPING (including AppendContentToolHandler for obsidian_append_to_file) and adds them to tool_handlers based on INCLUDE_TOOLS env var.
    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")

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