Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_append_to_file

Append text to a specified file in your Obsidian vault, creating it if missing. Enables efficient content updates and data integration within your vault.

Instructions

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

Input Schema

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

Implementation Reference

  • The AppendContentToolHandler class provides the core implementation of the 'obsidian_append_to_file' tool, including its schema definition, description, and the run_tool method that performs the append operation by calling api.append_content.
    class AppendContentToolHandler(ToolHandler): def __init__(self): super().__init__(TOOL_APPEND_CONTENT) def get_tool_description(self): return Tool( name=self.name, description="Append content to a new or existing file in the vault.", 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"] } ) 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']}" ) ]
  • The TOOL_MAPPING dictionary registers the 'obsidian_append_to_file' tool (via tools.TOOL_APPEND_CONTENT) by mapping its name to the AppendContentToolHandler class. This mapping is used in register_tools() to instantiate and add the handler to the MCP server.
    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 client's append_content method, which performs the actual HTTP POST request to the Obsidian API endpoint to append the given content to the specified file path.
    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 iterates over the TOOL_MAPPING, instantiates the handler for each included tool (including obsidian_append_to_file), and adds it to the tool_handlers dictionary used by the 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")

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