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 handler function that implements the get_links tool logic by extracting wikilinks ([[...]]) and markdown links ([text](file.md)) from the content of the specified note and returning 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 (registration)The tool registration entry in the tools array, including name, description, and input schema, used by the ListToolsRequestHandler.{ 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 dispatch case in the main CallToolRequestHandler switch statement that routes calls to the get_links handler.case "get_links": result = await handleGetLinks(args as { path: string }); break;
- src/index.ts:246-255 (schema)The input schema defining the expected arguments for the get_links tool (path: string).inputSchema: { type: "object", properties: { path: { type: "string", description: "Path to the note", }, }, required: ["path"], },