obsidian_patch_content
Insert content at specific locations in Obsidian notes using headings, blocks, or frontmatter. Add, prepend, or replace content within your vault's files with precise targeting.
Instructions
Insert content at specific locations within notes using headings, blocks, or frontmatter.
CRITICAL: For heading targets, you MUST provide the FULL HIERARCHICAL PATH.
Args:
params (PatchContentInput): Contains:
- filepath (str): Path to file
- target_type (TargetType): 'heading', 'block', or 'frontmatter'
- target (str): See examples below for correct format
- operation (PatchOperation): 'append', 'prepend', or 'replace'
- content (str): Content to insert
Returns:
str: Success message with patch details
HEADING PATH EXAMPLES (MUST use full path with '/'):
✅ CORRECT:
- target="Introduction" (for top-level # Introduction)
- target="Methods/Data Collection" (for ## Data Collection under # Methods)
- target="Results/Analysis/Statistical Tests" (for ### Statistical Tests under ## Analysis under # Results)
❌ WRONG:
- target="Data Collection" (missing parent "Methods")
- target="Statistical Tests" (missing parents "Results/Analysis")
BLOCK REFERENCE EXAMPLE:
- target_type="block", target="^unique-block-id"
FRONTMATTER EXAMPLE:
- target_type="frontmatter", target="tags"
Note: Always read the file first to see the exact heading structure before patching.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Input Schema (JSON Schema)
{
"properties": {
"params": {
"$ref": "#/$defs/PatchContentInput"
}
},
"required": [
"params"
],
"type": "object"
}