Skip to main content
Glama
disnet
by disnet

migrate_links

Scan existing notes to populate link tables for a one-time migration in the Flint Note system, enabling AI collaboration through organized markdown files.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoForce migration even if link tables already contain data

Implementation Reference

  • Core handler function for the 'migrate_links' MCP tool. Scans all notes in the vault, extracts links using LinkExtractor, stores them in note_links and external_links tables, handles errors per note, and returns migration statistics.
    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
        };
      }
    };
  • JSON Schema definition for the 'migrate_links' tool inputs, defining optional 'force' boolean and 'vault_id' string parameters.
    {
      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.'
          }
        }
      }
    }
  • Registration of the 'migrate_links' tool handler in the MCP server's CallToolRequestSchema switch statement, dispatching to LinkHandlers.handleMigrateLinks.
    case 'migrate_links':
      return await this.linkHandlers.handleMigrateLinks(
        args as unknown as { force?: boolean; vault_id?: string }
      );
  • Tool metadata registration for 'migrate_links' in the MCP server's ListToolsRequestSchema response, including name, description, and input schema.
      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
          }
        }
      }
    }
  • Validation rules used by validateToolArgs('migrate_links', args) for input argument checking.
    migrate_links: [
      {
        field: 'force',
        required: false,
        type: 'boolean'
      },
      {
        field: 'vault_id',
        required: false,
        type: 'string',
        allowEmpty: false
      }
    ],
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'Scan all existing notes' and 'one-time migration,' hinting at a potentially resource-intensive or irreversible operation, but fails to specify critical details like whether it's read-only, destructive, requires specific permissions, has side effects, or how it handles errors. This leaves significant gaps for a tool that likely modifies data.

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?

The description is a single, efficient sentence that front-loads the key action and purpose without unnecessary words. Every part ('Scan all existing notes,' 'populate the link tables,' 'one-time migration') earns its place by conveying essential information concisely.

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 tool's complexity (likely a data migration operation), lack of annotations, and no output schema, the description is insufficient. It doesn't cover behavioral aspects like safety, performance impact, or return values, leaving the agent with incomplete context for proper invocation. This is inadequate for a tool that could have significant side effects.

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

Parameters3/5

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

The input schema has 100% description coverage for its single parameter ('force'), so the schema fully documents the parameter. The description does not add any additional meaning beyond what the schema provides (e.g., it doesn't explain the implications of forcing migration). Given the high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but doesn't need to.

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 action ('Scan all existing notes and populate the link tables') and purpose ('one-time migration'), specifying the verb and resource. It distinguishes from siblings like 'find_broken_links' or 'get_note_links' by focusing on migration rather than querying, though it doesn't explicitly contrast with all siblings.

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?

The description implies usage as a 'one-time migration' tool, suggesting it's for initial setup or maintenance, but provides no explicit guidance on when to use it versus alternatives (e.g., when to choose this over 'find_broken_links' for link-related tasks) or any prerequisites. It lacks clear exclusions or context for decision-making.

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

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