Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_vault_graph

Read-only

Retrieve a vault's link graph as structured data (nodes, edges, adjacency lists) for analyzing note relationships.

Instructions

Export the vault link graph as nodes, edges, and adjacency lists.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultNoOptional configured vault name. Defaults to the server default vault.
includeUnresolvedNo
limitNo

Implementation Reference

  • src/tools.ts:832-855 (registration)
    Registration and handler for the 'obsidian_vault_graph' tool. It exports the vault link graph as nodes, edges, and adjacency lists, with optional unresolved link filtering and a limit.
    tool(
      "obsidian_vault_graph",
      "Export the vault link graph as nodes, edges, and adjacency lists.",
      {
        vault: vaultArg,
        includeUnresolved: z.boolean().optional().default(true),
        limit: z.number().int().min(1).max(10000).optional().default(5000),
      },
      async (args) => {
        const graph = buildGraph(await loadNotes(vaults, args.vault));
        const edges = graph.edges.filter((edge) => args.includeUnresolved || !edge.unresolved).slice(0, args.limit);
        const adjacency = new Map<string, string[]>();
        for (const edge of edges) {
          if (edge.unresolved) continue;
          adjacency.set(edge.source, [...(adjacency.get(edge.source) ?? []), edge.target]);
        }
        return {
          nodes: graph.nodes.slice(0, args.limit),
          edges,
          adjacency: Object.fromEntries([...adjacency.entries()].map(([key, value]) => [key, [...new Set(value)].sort()])),
        };
      },
      { readOnlyHint: true },
    );
  • VaultGraph type definition with nodes, edges, and byPath map.
    export type VaultGraph = {
      nodes: GraphNode[];
      edges: GraphEdge[];
      byPath: Map<string, GraphNode>;
    };
  • GraphNode type definition: path, title, tags, outDegree, inDegree.
    export type GraphNode = {
      path: string;
      title: string;
      tags: string[];
      outDegree: number;
      inDegree: number;
    };
  • GraphEdge type definition: source, target, rawTarget, kind, unresolved, line.
    export type GraphEdge = {
      source: string;
      target: string;
      rawTarget: string;
      kind: "wiki" | "markdown";
      unresolved: boolean;
      line: number;
    };
  • buildGraph function - constructs a VaultGraph from NoteRecord[] by extracting wiki and markdown links, resolving targets, and computing in/out degrees.
    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])) };
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=true, so the description adds no new behavioral insights. It correctly implies no destruction but does not describe performance implications of the limit parameter or the impact of includeUnresolved. Score is adequate but lacks extra context.

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?

A single, front-loaded sentence with no waste. Every word adds value, and the structure is optimal for quick parsing.

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

Completeness2/5

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

The description is too terse given three parameters and no output schema. It does not clarify the return format (e.g., what 'adjacency lists' means), the effect of the limit parameter, or how includeUnresolved affects the graph.

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

Parameters2/5

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

Schema description coverage is low (33%), and the overall description does not explain any of the three parameters. The agent must infer meaning from parameter names alone. This is insufficient for correct invocation.

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 action ('Export'), the resource ('vault link graph'), and the output format ('nodes, edges, and adjacency lists'). It distinguishes well from sibling tools like obsidian_graph_stats (statistics) and obsidian_traverse_graph (traversal).

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 guidance on when to use this tool versus alternatives such as obsidian_graph_stats or obsidian_traverse_graph. No explicit 'when to use' or 'when not to use' instructions.

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