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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states a read operation ('Get'), implying non-destructive behavior, but doesn't disclose permissions, rate limits, output format, or error handling. This is inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with the core purpose, zero waste. Efficiently conveys the essential action without unnecessary details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, but an output schema exists, the description is minimally adequate. It covers the basic purpose but lacks behavioral details and parameter guidance, leaving gaps for a tool with one required parameter.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions 'from a note' which hints at the 'path' parameter referring to a note, but doesn't specify format (e.g., file path, note title) or constraints. This adds minimal meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('all links from a note to other notes'), specifying outgoing links. It distinguishes from sibling 'get_backlinks' by directionality, though not explicitly named. It's not fully specific about scope (e.g., format or depth), keeping it at 4.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus alternatives like 'get_backlinks' (for incoming links) or 'get_link_graph' (for broader link analysis). The description implies usage for outgoing links only, but lacks context on prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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