get_links
Extract all internal wikilinks and markdown links from an Obsidian note to analyze connections and references within your vault.
Instructions
Get all internal links (wikilinks and markdown links) from a note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the note |
Implementation Reference
- src/index.ts:673-692 (handler)The main handler function that extracts wikilinks and markdown links from a note's content and returns them as JSON.async function handleGetLinks(args: { path: string }): Promise<string> { const content = await handleReadNote(args); // Find wikilinks [[link]] and [[link|alias]] const wikiLinkRegex = /\[\[([^\]|]+)(?:\|[^\]]+)?\]\]/g; const wikiLinks: string[] = []; let match; while ((match = wikiLinkRegex.exec(content)) !== null) { wikiLinks.push(match[1]); } // Find markdown links [text](link.md) const mdLinkRegex = /\[([^\]]+)\]\(([^)]+\.md)\)/g; const mdLinks: string[] = []; while ((match = mdLinkRegex.exec(content)) !== null) { mdLinks.push(match[2]); } return JSON.stringify({ wikiLinks, markdownLinks: mdLinks }, null, 2); }
- src/index.ts:242-256 (schema)The tool schema definition including name, description, and input schema for the get_links tool.{ name: "get_links", description: "Get all internal links (wikilinks and markdown links) from a note", inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the note", }, }, required: ["path"], }, },
- src/index.ts:914-916 (registration)The switch case in the main tool call handler that routes calls to get_links to the handleGetLinks function.case "get_links": result = await handleGetLinks(args as { path: string }); break;