Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesPath to the note

Implementation Reference

  • 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); }
  • 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;

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