Update Fenced Block
blocks.updateUpdate a fenced block's content in an Obsidian note while preserving its fences and language tag. Locate the block by blockId or index; the language guard prevents mismatched updates. The replacement source becomes the new block body.
Instructions
Replace one fenced block's body source-preservingly — the surrounding fences, language tag, and neighbouring content are untouched. Locate the block by blockId or index. language acts as a guard: if the located block is not of the declared language, the update fails. source is the replacement body WITHOUT the surrounding ``` fences. Idempotent — re-running with identical inputs is a no-op on the file contents. Destructive — overwrites the previous block body in place.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Examples:
Example 1 — Replace the first Mermaid diagram in a note:
{
"filePath": "Diagrams/system-overview.md",
"language": "mermaid",
"index": 0,
"source": "flowchart TD\n A --> B"
}Example 2 — Update a DQL query block by stable id:
{
"filePath": "Dashboards/Inbox.md",
"language": "dataview",
"blockId": "inbox-open",
"source": "TASK\nFROM #inbox\nWHERE !completed"
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path of the note containing the block. | |
| language | Yes | Language of the block being updated. Acts as a guard: update fails if the targeted block's real language does not match. | |
| source | Yes | Replacement source for the block body, WITHOUT the surrounding ``` fences. Surrounding newlines and indentation are preserved by the tool. | |
| blockId | No | Stable block identifier (e.g. `^abc123`). Takes precedence over `index` when both are given. | |
| index | No | 0-based position of the block within its language group in the file. Use when no blockId is available. Defaults to 0 (the first block). | |
| vaultPath | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| changed | Yes | True if the tool altered vault state on this call; false if it was a no-op. | |
| target | Yes | The path or identifier the tool acted on. | |
| summary | Yes | Short human-readable summary of what happened. |