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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server/link-handlers.ts:136-181 (handler)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 }; }
- src/core/link-extractor.ts:323-327 (helper)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` ); }
- src/server/tool-schemas.ts:909-917 (schema)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: [] } },
- src/server.ts:1336-1339 (registration)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 } );
- src/server/validation.ts:847-854 (schema)Input validation rules for find_broken_links tool arguments (optional vault_id).find_broken_links: [ { field: 'vault_id', required: false, type: 'string', allowEmpty: false } ],