Skip to main content
Glama
sureshsankaran

Obsidian Tools MCP Server

get_backlinks

Discover all notes linking to a specific note in your Obsidian vault to understand connections and references.

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 scans all notes in the vault for wikilinks and markdown links pointing to the specified path and returns a JSON list of backlinking notes.
    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 schema definition including name, description, and input schema for validation and 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 CallTool request handler that routes calls to the get_backlinks 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