Get backlinks
obsidian_get_backlinksRetrieve backlinks for a specific note in Obsidian. Provide the note name or path to see which other notes link to it.
Instructions
Returns notes that link to the target note.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| vault | No | Vault name to target. Optional — defaults to the most recently focused vault. | |
| file | No | Note name resolved as a wikilink (e.g. 'My Note'). Provide either `file` or `path`. | |
| path | No | Vault-root-relative path to the note (e.g. 'Folder/My Note.md'). Provide either `file` or `path`. |
Implementation Reference
- src/tools.ts:626-629 (handler)Handler for obsidian_get_backlinks. Calls requireFileTarget to validate input, then delegates to runJson('backlinks', ...) which invokes the Obsidian CLI 'backlinks' command and parses the JSON output.
handler: async ({ vault, file, path }) => { requireFileTarget({ file, path }); return runJson("backlinks", { vault, params: { file, path } }); }, - src/tools.ts:16-29 (schema)Input schema for file targeting: accepts optional `file` (wikilink-style name) or `path` (vault-relative path).
const FileTargetArg = { file: z .string() .optional() .describe( "Note name resolved as a wikilink (e.g. 'My Note'). Provide either `file` or `path`.", ), path: z .string() .optional() .describe( "Vault-root-relative path to the note (e.g. 'Folder/My Note.md'). Provide either `file` or `path`.", ), }; - src/tools.ts:7-14 (schema)Input schema for the optional vault parameter, shared across all tools.
const VaultArg = { vault: z .string() .optional() .describe( "Vault name to target. Optional — defaults to the most recently focused vault.", ), }; - src/tools.ts:620-630 (registration)Tool definition object for obsidian_get_backlinks in the tools array. Registered by index.ts via server.registerTool().
{ name: "obsidian_get_backlinks", title: "Get backlinks", description: "Returns notes that link to the target note.", inputSchema: { ...VaultArg, ...FileTargetArg }, annotations: { readOnlyHint: true, openWorldHint: false }, handler: async ({ vault, file, path }) => { requireFileTarget({ file, path }); return runJson("backlinks", { vault, params: { file, path } }); }, }, - src/tools.ts:31-37 (helper)Helper that validates that either `file` or `path` is provided; throws if both are missing.
function requireFileTarget(input: { file?: string; path?: string }) { if (!input.file && !input.path) { throw new Error( "Either `file` (wikilink name) or `path` (vault-relative path) must be provided.", ); } }