Read Fenced Block
blocks.readRead the source and language-specific metadata of a fenced code block from an Obsidian note. Locate by block ID (preferred) or zero-based index within its language group. Requires file path and block language for correct parsing.
Instructions
Read one fenced block's source and language-specific metadata. Locate the block by blockId (preferred, stable) or index (0-based within the language group in the file; defaults to 0). language is required so the tool can dispatch to the correct parser and return the right metadata (Mermaid directives, Dataview DQL parts, etc.). Fails with not_found when no block matches the locator. Read-only.
Operates on the session-active vault (see vault.current — selectable via vault.select) unless an explicit vaultPath argument is passed, which always wins.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Path of the note containing the block. | |
| language | Yes | Language of the block to read (required so `blocks.read` can dispatch to the correct parser). | |
| 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 |
|---|---|---|---|
| filePath | Yes | ||
| language | Yes | Fenced-code-block language. `dataview` = raw DQL query block; `dataviewjs` = inline JavaScript block; `mermaid` = diagram block. | |
| id | No | ||
| source | Yes | The block's body source (without fences). |