Skip to main content
Glama

get_backlinks

Find all notes linking to a specific note in your Obsidian vault to track references and connections.

Instructions

Find all notes that link to a specific note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the note to find backlinks for

Implementation Reference

  • The main handler function that implements the get_backlinks tool. It iterates over all notes in the vault, checks for wikilinks ([[note]]) and markdown links to the target path using regex, and returns a JSON array of paths to notes that link to it.
    async function handleGetBacklinks(args: { path: string }): Promise<string> { const noteName = path.basename(args.path, ".md"); const allNotes = await getAllNotes(); const backlinks: string[] = []; for (const notePath of allNotes) { if (notePath === args.path) continue; const fullPath = path.join(VAULT_PATH, notePath); const content = await fs.readFile(fullPath, "utf-8"); // Check for wikilinks to this note const wikiLinkPattern = new RegExp(`\\[\\[${noteName}(\\|[^\\]]+)?\\]\\]`); // Check for markdown links const mdLinkPattern = new RegExp(`\\]\\(${args.path}\\)`); if (wikiLinkPattern.test(content) || mdLinkPattern.test(content)) { backlinks.push(notePath); } } return JSON.stringify(backlinks, null, 2); }
  • The tool definition object containing the name, description, and input schema for validation and tool listing.
    { name: "get_backlinks", description: "Find all notes that link to a specific note", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the note to find backlinks for", }, }, required: ["path"], }, },
  • src/index.ts:917-919 (registration)
    The dispatch case in the central tool call handler that routes 'get_backlinks' calls to the appropriate handler function.
    case "get_backlinks": result = await handleGetBacklinks(args as { path: string }); break;

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

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