Skip to main content
Glama
disnet
by disnet

get_note_links

Retrieve all links associated with a specific note, including incoming, outgoing internal, and external connections, to analyze relationships and connections within your note vault.

Instructions

Get all links for a specific note (incoming, outgoing internal, and external)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesNote identifier (type/filename format)

Implementation Reference

  • Primary execution logic for the get_note_links tool: validates args, resolves vault/DB, checks note existence, extracts links via LinkExtractor.getLinksForNote, returns structured JSON response.
    handleGetNoteLinks = async (args: { identifier: string; vault_id?: string }) => {
      try {
        // Validate arguments
        validateToolArgs('get_note_links', args);
    
        const { hybridSearchManager } = await this.resolveVaultContext(args.vault_id);
        const db = await hybridSearchManager.getDatabaseConnection();
        const noteId = this.generateNoteIdFromIdentifier(args.identifier);
    
        // Check if note exists
        const note = await db.get('SELECT id FROM notes WHERE id = ?', [noteId]);
        if (!note) {
          throw new Error(`Note not found: ${args.identifier}`);
        }
    
        const links = await LinkExtractor.getLinksForNote(noteId, db);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  success: true,
                  note_id: noteId,
                  links: links
                },
                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
        };
      }
    };
  • MCP tool dispatch registration in CallToolRequestSchema handler switch statement. Maps 'get_note_links' calls to LinkHandlers.handleGetNoteLinks method.
    case 'get_note_links':
      return await this.linkHandlers.handleGetNoteLinks(
        args as unknown as { identifier: string; vault_id?: string }
      );
    
    case 'get_backlinks':
      return await this.linkHandlers.handleGetBacklinks(
        args as unknown as { identifier: string; vault_id?: string }
      );
    
    case 'find_broken_links':
      return await this.linkHandlers.handleFindBrokenLinks(
        args as unknown as { vault_id?: string }
      );
    
    case 'search_by_links':
      return await this.linkHandlers.handleSearchByLinks(
        args as unknown as {
          has_links_to?: string[];
          linked_from?: string[];
          external_domains?: string[];
          broken_links?: boolean;
          vault_id?: string;
        }
      );
    
    case 'migrate_links':
      return await this.linkHandlers.handleMigrateLinks(
        args as unknown as { force?: boolean; vault_id?: string }
      );
  • Input schema definition for get_note_links tool, defining required 'identifier' parameter and optional 'vault_id'.
      name: 'get_note_links',
      description:
        'Get all links for a specific note (incoming, outgoing internal, and external)',
      inputSchema: {
        type: 'object',
        properties: {
          identifier: {
            type: 'string',
            description: 'Note identifier (type/filename format)'
          },
          vault_id: {
            type: 'string',
            description:
              'Optional vault ID to operate on. If not provided, uses the current active vault.'
          }
        },
        required: ['identifier']
      }
    },
  • Runtime argument validation rules for get_note_links tool args, ensuring identifier format 'type/filename'.
    get_note_links: [
      {
        field: 'identifier',
        required: true,
        type: 'string',
        allowEmpty: false,
        customValidator: (value: any) => {
          if (!value.includes('/')) {
            return 'identifier must be in format "type/filename"';
          }
          const parts = value.split('/');
          if (parts.length !== 2 || !parts[0] || !parts[1]) {
            return 'identifier must be in format "type/filename" with both parts non-empty';
          }
          return null;
        }
      },
      {
        field: 'vault_id',
        required: false,
        type: 'string',
        allowEmpty: false
      }
    ],
  • src/server.ts:158-162 (registration)
    Instantiation of LinkHandlers class instance used by get_note_links (and related link tools), injecting vault resolver and note ID generator.
    // Initialize link handlers
    this.linkHandlers = new LinkHandlers(
      this.#resolveVaultContext.bind(this),
      this.#generateNoteIdFromIdentifier.bind(this)
    );

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