Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_links

Read-only

Retrieve outgoing links, backlinks, tags, and frontmatter for any note in your Obsidian vault. Ideal for analyzing note connections and metadata.

Instructions

Return outgoing links, backlinks, tags, and frontmatter for one note.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
pathYesVault-relative path. Absolute paths and traversal are rejected.

Implementation Reference

  • The 'obsidian_links' tool handler: loads all notes, builds the graph, and returns outgoing links, backlinks, tags, and frontmatter for one note.
    tool(
      "obsidian_links",
      "Return outgoing links, backlinks, tags, and frontmatter for one note.",
      { vault: vaultArg, path: pathArg },
      async (args) => {
        const notes = await loadNotes(vaults, args.vault);
        const graph = buildGraph(notes);
        const note = notes.find((item) => item.path === vaults.notePath(args.path) || item.path.endsWith(`/${vaults.notePath(args.path)}`));
        return {
          path: args.path,
          outgoing: outgoing(graph, args.path),
          backlinks: backlinks(graph, args.path),
          note: note ? { title: note.title, tags: note.tags, frontmatter: note.frontmatter } : null,
        };
      },
      { readOnlyHint: true },
    );
  • The `outgoing()` function filters the graph for edges where the source matches the given path. Used by obsidian_links handler.
    export function outgoing(graph: VaultGraph, sourcePath: string): GraphEdge[] {
      const source = resolveGraphPath(graph, sourcePath);
      if (!source) return [];
      return graph.edges.filter((edge) => !edge.unresolved && edge.source === source.path);
    }
  • The `backlinks()` function filters the graph for edges where the target matches the given path. Used by obsidian_links handler.
    export function backlinks(graph: VaultGraph, targetPath: string): GraphEdge[] {
      const target = resolveGraphPath(graph, targetPath);
      if (!target) return [];
      return graph.edges.filter((edge) => !edge.unresolved && edge.target === target.path);
    }
  • The `buildGraph()` function constructs the full vault graph from all notes, creating nodes and edges from wiki/Markdown links. Used by obsidian_links handler.
    export function buildGraph(notes: NoteRecord[]): VaultGraph {
      const resolver = createResolver(notes);
      const edges: GraphEdge[] = [];
      for (const note of notes) {
        for (const link of extractWikiLinks(note.content)) {
          const target = resolver(link.target);
          edges.push({
            source: note.path,
            target: target ?? link.target,
            rawTarget: link.target,
            kind: "wiki",
            unresolved: !target,
            line: link.line,
          });
        }
        for (const link of extractMarkdownLinks(note.content)) {
          const target = resolver(link.target);
          edges.push({
            source: note.path,
            target: target ?? link.target,
            rawTarget: link.target,
            kind: "markdown",
            unresolved: !target,
            line: link.line,
          });
        }
      }
      const outCounts = countBy(edges.filter((e) => !e.unresolved), (edge) => edge.source);
      const inCounts = countBy(edges.filter((e) => !e.unresolved), (edge) => edge.target);
      const nodes = notes.map((note) => ({
        path: note.path,
        title: note.title,
        tags: note.tags,
        outDegree: outCounts.get(note.path) ?? 0,
        inDegree: inCounts.get(note.path) ?? 0,
      }));
      return { nodes, edges, byPath: new Map(nodes.map((node) => [node.path, node])) };
    }
  • src/tools.ts:147-153 (registration)
    The tool is registered inside `registerObsidianTools()` via the helper function `tool()` which calls `server.tool()` with schema, annotations, and handler.
          tags: extractAllTags(read.text),
          stat: { size: read.stat.size, mtime: read.stat.mtime.toISOString(), ctime: read.stat.ctime.toISOString() },
          links: args.includeLinks ? { wiki: extractWikiLinks(read.text), markdown: extractMarkdownLinks(read.text) } : undefined,
        };
      },
      { readOnlyHint: true },
    );
Behavior4/5

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

The annotations already declare readOnlyHint=true and destructiveHint=false. The description adds context that this tool is a combined retrieval of multiple data types, which is beyond the annotations. No contradictions.

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?

The description is a single sentence of 10 words, front-loading the purpose. Every word is essential with no filler.

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

Completeness4/5

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

Given there is no output schema, the description lists the types of data returned, which is sufficient for understanding the tool's scope. It could optionally mention the format, but it is reasonably complete for a simple read tool.

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?

Input schema coverage is 100%, and both parameters are well-described in the schema. The description adds no additional parameter semantics beyond the schema. Baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states the verb 'return' and specifies the exact resources: outgoing links, backlinks, tags, and frontmatter for one note. This differentiates it from sibling tools like obsidian_get_backlinks or obsidian_get_frontmatter, which are more specific.

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

Usage Guidelines3/5

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

The description implies use when wanting all link-related data for a single note, but does not explicitly state when to use this tool versus the more granular sibling tools. No exclusion criteria or when-not-to-use guidance is provided.

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/jagoff/obsidian-mcp'

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