Skip to main content
Glama
sureshsankaran

Obsidian Tools MCP Server

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 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;
  • 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"],
    },

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