Skip to main content
Glama

migrate_links

Scan and migrate all existing notes to populate link tables in Flint Note. This one-time tool ensures accurate note connections, even if link tables contain data, by optionally forcing migration.

Instructions

Scan all existing notes and populate the link tables (one-time migration)

Input Schema

NameRequiredDescriptionDefault
forceNoForce migration even if link tables already contain data

Input Schema (JSON Schema)

{ "properties": { "force": { "default": false, "description": "Force migration even if link tables already contain data", "type": "boolean" } }, "type": "object" }

Implementation Reference

  • Main handler function that executes the migrate_links tool: validates args, checks if links exist (unless force), extracts links from all notes using LinkExtractor, stores them in DB tables.
    handleMigrateLinks = async (args: { force?: boolean; vault_id?: string }) => { try { // Validate arguments validateToolArgs('migrate_links', args); const { hybridSearchManager } = await this.resolveVaultContext(args.vault_id); const db = await hybridSearchManager.getDatabaseConnection(); // Check if migration is needed if (!args.force) { const existingLinks = await db.get<{ count: number }>( 'SELECT COUNT(*) as count FROM note_links' ); if (existingLinks && existingLinks.count > 0) { return { content: [ { type: 'text', text: JSON.stringify( { success: false, message: 'Link tables already contain data. Use force=true to migrate anyway.', existing_links: existingLinks.count }, null, 2 ) } ] }; } } // Get all notes from the database const notes = await db.all<{ id: string; content: string }>( 'SELECT id, content FROM notes' ); let processedCount = 0; let errorCount = 0; const errors: string[] = []; for (const note of notes) { try { // Extract links from note content const extractionResult = LinkExtractor.extractLinks(note.content); // Store the extracted links await LinkExtractor.storeLinks(note.id, extractionResult, db); processedCount++; } catch (error) { errorCount++; const errorMessage = error instanceof Error ? error.message : 'Unknown error'; errors.push(`${note.id}: ${errorMessage}`); } } return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: 'Link migration completed', total_notes: notes.length, processed: processedCount, errors: errorCount, error_details: errors.length > 0 ? errors.slice(0, 10) : undefined // Limit error details to first 10 }, 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 }; } };
  • Registration of the migrate_links tool in the MCP server's CallToolRequestSchema handler, dispatching to LinkHandlers.handleMigrateLinks
    case 'migrate_links': return await this.linkHandlers.handleMigrateLinks( args as unknown as { force?: boolean; vault_id?: string } );
  • Tool schema definition for migrate_links provided in ListToolsRequestSchema response
    name: 'migrate_links', description: 'Scan all existing notes and populate the link tables (one-time migration)', inputSchema: { type: 'object', properties: { force: { type: 'boolean', description: 'Force migration even if link tables already contain data', default: false } } } }
  • Centralized tool schema definition for migrate_links (potentially used for documentation or generation) with vault_id support
    { name: 'migrate_links', description: 'Scan all existing notes and populate the link tables (one-time migration)', inputSchema: { type: 'object', properties: { force: { type: 'boolean', description: 'Force migration even if link tables already contain data', default: false }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' } } } }
  • Validation rules for migrate_links tool arguments used in validateToolArgs('migrate_links', args)
    migrate_links: [ { field: 'force', required: false, type: 'boolean' }, { 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