Skip to main content
Glama
MarkusPfundstein

MCP server for Obsidian

obsidian_patch_content

Insert content into Obsidian notes relative to headings, blocks, or frontmatter fields using append, prepend, or replace operations.

Instructions

Insert content into an existing note relative to a heading, block reference, or frontmatter field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the file (relative to vault root)
operationYesOperation to perform (append, prepend, or replace)
target_typeYesType of target to patch
targetYesTarget identifier (heading path, block reference, or frontmatter field)
contentYesContent to insert

Implementation Reference

  • Registers the PatchContentToolHandler for the 'obsidian_patch_content' tool.
    add_tool_handler(tools.PatchContentToolHandler())
  • Executes the tool by validating arguments and calling obsidian.patch_content API method.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]: if not all(k in args for k in ["filepath", "operation", "target_type", "target", "content"]): raise RuntimeError("filepath, operation, target_type, target and content arguments required") api = obsidian.Obsidian(api_key=api_key, host=obsidian_host) api.patch_content( args.get("filepath", ""), args.get("operation", ""), args.get("target_type", ""), args.get("target", ""), args.get("content", "") ) return [ TextContent( type="text", text=f"Successfully patched content in {args['filepath']}" ) ]
  • Defines the input schema and description for the obsidian_patch_content tool.
    def get_tool_description(self): return Tool( name=self.name, description="Insert content into an existing note relative to a heading, block reference, or frontmatter field.", inputSchema={ "type": "object", "properties": { "filepath": { "type": "string", "description": "Path to the file (relative to vault root)", "format": "path" }, "operation": { "type": "string", "description": "Operation to perform (append, prepend, or replace)", "enum": ["append", "prepend", "replace"] }, "target_type": { "type": "string", "description": "Type of target to patch", "enum": ["heading", "block", "frontmatter"] }, "target": { "type": "string", "description": "Target identifier (heading path, block reference, or frontmatter field)" }, "content": { "type": "string", "description": "Content to insert" } }, "required": ["filepath", "operation", "target_type", "target", "content"] } )

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/MarkusPfundstein/mcp-obsidian'

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