Skip to main content
Glama
disnet
by disnet

find_broken_links

Identify broken wikilinks in your note vault to maintain content integrity and fix missing references.

Instructions

Find all broken wikilinks (links to non-existent notes)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler: resolves vault DB connection, calls LinkExtractor.findBrokenLinks(db), returns JSON with broken_links array and count or error.
    handleFindBrokenLinks = async (args?: { vault_id?: string }) => {
      try {
        // Validate arguments
        if (args) {
          validateToolArgs('find_broken_links', args);
        }
    
        const { hybridSearchManager } = await this.resolveVaultContext(args?.vault_id);
        const db = await hybridSearchManager.getDatabaseConnection();
        const brokenLinks = await LinkExtractor.findBrokenLinks(db);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  success: true,
                  broken_links: brokenLinks,
                  count: brokenLinks.length
                },
                null,
                2
              )
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  success: false,
                  error: errorMessage
                },
                null,
                2
              )
            }
          ],
          isError: true
        };
      }
  • Core implementation: SQL query to find all broken wikilinks (note_links with NULL target_note_id).
    static async findBrokenLinks(db: DatabaseConnection): Promise<NoteLinkRow[]> {
      return await db.all<NoteLinkRow>(
        `SELECT * FROM note_links WHERE target_note_id IS NULL ORDER BY source_note_id, line_number`
      );
    }
  • Tool schema definition: name, description, and empty inputSchema (optional vault_id handled in handler).
    {
      name: 'find_broken_links',
      description: 'Find all broken wikilinks (links to non-existent notes)',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      }
    },
  • MCP server registration: maps 'find_broken_links' tool calls to LinkHandlers.handleFindBrokenLinks.
    case 'find_broken_links':
      return await this.linkHandlers.handleFindBrokenLinks(
        args as unknown as { vault_id?: string }
      );
  • Input validation rules for find_broken_links tool arguments (optional vault_id).
    find_broken_links: [
      {
        field: 'vault_id',
        required: false,
        type: 'string',
        allowEmpty: false
      }
    ],

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/disnet/flint-note'

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