Skip to main content
Glama
jagoff

obsidian-mcp-complete

by jagoff

obsidian_find_broken_links

Read-only

Find wiki and Markdown links that point to nonexistent notes in your Obsidian vault.

Instructions

List wiki/Markdown links that do not resolve to a note in the vault.

Input Schema

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

Implementation Reference

  • src/tools.ts:800-809 (registration)
    Registration of the 'obsidian_find_broken_links' tool. Includes schema (vault, limit, offset) and inline handler.
    tool(
      "obsidian_find_broken_links",
      "List wiki/Markdown links that do not resolve to a note in the vault.",
      { vault: vaultArg, limit: z.number().int().min(1).max(2000).optional().default(500), offset: z.number().int().min(0).optional().default(0) },
      async (args) => {
        const broken = buildGraph(await loadNotes(vaults, args.vault)).edges.filter((edge) => edge.unresolved);
        return { total: broken.length, offset: args.offset, links: broken.slice(args.offset, args.offset + args.limit) };
      },
      { readOnlyHint: true },
    );
  • Handler function: loads all notes, builds the link graph via buildGraph(), filters edges with unresolved=true, and returns paginated results.
    async (args) => {
      const broken = buildGraph(await loadNotes(vaults, args.vault)).edges.filter((edge) => edge.unresolved);
      return { total: broken.length, offset: args.offset, links: broken.slice(args.offset, args.offset + args.limit) };
    },
  • buildGraph() iterates over all notes, extracts wiki and markdown links, and creates GraphEdge entries. The 'unresolved' flag is set when the resolver cannot find a matching note, which is the core logic that powers broken-link detection.
    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])) };
    }
  • createResolver() builds lookup maps (by path, by stem) from all note records. Returns a resolver function that returns the resolved note path or null if the link target cannot be matched — this null return is what sets unresolved=true on edges.
    export function createResolver(notes: NoteRecord[]): (target: string) => string | null {
      const byPath = new Map<string, string>();
      const byStem = new Map<string, string[]>();
      for (const note of notes) {
        byPath.set(note.path.toLowerCase(), note.path);
        byPath.set(note.path.replace(/\.md$/i, "").toLowerCase(), note.path);
        byPath.set(path.posix.basename(note.path).toLowerCase(), note.path);
        const stem = noteStem(note.path).toLowerCase();
        const list = byStem.get(stem) ?? [];
        list.push(note.path);
        byStem.set(stem, list);
      }
      return (target: string) => {
        const clean = normalizeNoteTarget(target).toLowerCase();
        const direct = byPath.get(clean) ?? byPath.get(`${clean}.md`);
        if (direct) return direct;
        const stem = path.posix.basename(clean).replace(/\.md$/i, "");
        const matches = byStem.get(stem);
        return matches?.length === 1 ? matches[0] : null;
      };
    }
  • Zod schema for obsidian_find_broken_links: vault (optional string), limit (1-2000, default 500), offset (0+, default 0).
    { vault: vaultArg, limit: z.number().int().min(1).max(2000).optional().default(500), offset: z.number().int().min(0).optional().default(0) },
Behavior3/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false, so the tool is read-only. The description does not add extra behavioral context (e.g., performance characteristics, scope of scanning, or error conditions). It is adequate but does not enrich the safety profile.

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

Conciseness4/5

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

The description is a single concise sentence that efficiently conveys the core purpose. However, it lacks structured breakdown of usage or parameters, which would improve utility without adding much length.

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?

Given the simple nature of the tool (list operation with 3 parameters, no output schema), the description should cover parameter usage and behavior (e.g., that it scans all notes). It omits these details, making it incomplete for agent invocation.

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%). Only the 'vault' parameter has a description; 'limit' and 'offset' lack any documentation in schema or description. The tool description does not explain these parameters, leaving the agent unaware of pagination and result limiting.

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 tool lists broken wiki/Markdown links that don't resolve to notes. The verb 'List' and resource 'broken links' are specific, but it does not differentiate from sibling tools like obsidian_find_orphans, which addresses a related but distinct concept.

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 is provided on when to use this tool versus alternatives, such as obsidian_find_orphans or obsidian_search. There is no mention of prerequisites, typical use cases, or when not to use it.

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