Skip to main content
Glama

get_outgoing_links

Extract all outgoing links from a specific note to other notes in your Obsidian vault, enabling you to analyze connections and understand relationships between your documents.

Instructions

Get all links from a note to other notes (outgoing links)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Core handler implementation: reads note content, extracts wikilinks using _extract_links, resolves each link to vault paths using _resolve_link, returns list of resolved paths.
    async def get_outgoing_links(self, relative_path: str) -> list[str]: """ Get all outgoing links from a note. Args: relative_path: Path to the note Returns: List of linked note paths (relative to vault) """ note = await self.read_note(relative_path) links = self._extract_links(note.content) # Resolve links to actual file paths resolved = [] for link in links: # Try to find the note in the vault resolved_path = self._resolve_link(link, relative_path) if resolved_path: resolved.append(resolved_path) return resolved
  • MCP tool registration decorator and wrapper function: validates input, calls vault.get_outgoing_links, formats results as numbered list string.
    @mcp.tool( name="get_outgoing_links", description="Get all links from a note to other notes (outgoing links)", ) async def get_outgoing_links(path: str) -> str: """ Get all outgoing links from a note. Args: path: Relative path to the note (e.g., "Projects/MCP.md") Returns: Formatted list of linked notes """ if not path or not path.strip(): return "Error: Path cannot be empty" if len(path) > 1000: return "Error: Path too long" context = _get_context() try: outgoing = await context.vault.get_outgoing_links(path) if not outgoing: return f"No outgoing links found in '{path}'" output = f"Found {len(outgoing)} outgoing link(s) from '{path}':\n\n" for i, link_path in enumerate(outgoing, 1): output += f"{i}. `{link_path}`\n" return output except FileNotFoundError: return f"Error: Note not found: {path}" except VaultSecurityError as e: return f"Error: Security violation: {e}" except Exception as e: logger.exception(f"Error getting outgoing links for {path}") return f"Error getting outgoing links: {e}"
  • Helper: Resolves a wikilink alias to an actual relative file path by checking direct path, same folder, and full vault search.
    def _resolve_link(self, link: str, source_path: str) -> str | None: """ Resolve a wikilink to an actual file path. Args: link: Link destination (e.g., "My Note" or "folder/My Note") source_path: Path of the source note (for relative links) Returns: Resolved path or None if not found """ # If link already has extension, use as-is if link.endswith(".md"): link_path = link else: link_path = f"{link}.md" # Try direct path first try: if self.note_exists(link_path): return link_path except VaultSecurityError: pass # Try in same folder as source source_dir = str(Path(source_path).parent) if source_dir != ".": try: same_folder_path = f"{source_dir}/{link_path}" if self.note_exists(same_folder_path): return same_folder_path except VaultSecurityError: pass # Search for file by name in entire vault for note_meta in self.list_notes(limit=10000): if note_meta.name == link or note_meta.path == link_path: return note_meta.path return None

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/getglad/obsidian_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server