Skip to main content
Glama

get_note_links

Extract incoming, outgoing, internal, and external links for a specific note to analyze or manage its connections within the Flint Note system.

Instructions

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

Input Schema

NameRequiredDescriptionDefault
identifierYesNote identifier (type/filename format)

Input Schema (JSON Schema)

{ "properties": { "identifier": { "description": "Note identifier (type/filename format)", "type": "string" } }, "required": [ "identifier" ], "type": "object" }

Implementation Reference

  • Main handler function for the get_note_links tool. Validates arguments, resolves vault context, verifies note existence, retrieves links using LinkExtractor.getLinksForNote, and returns structured JSON response with error handling.
    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 }; } };
  • Tool registration in MCP server's CallToolRequestSchema handler: maps 'get_note_links' to LinkHandlers.handleGetNoteLinks method.
    return await this.linkHandlers.handleGetNoteLinks( args as unknown as { identifier: string; vault_id?: string } );
  • JSON Schema definition for the get_note_links tool, specifying input parameters and requirements.
    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'] } },
  • Validation rules for get_note_links tool arguments, enforcing 'identifier' in 'type/filename' format.
    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 } ],
  • Core database query function that retrieves all outgoing internal/external links and incoming backlinks for a given note ID.
    static async getLinksForNote( noteId: string, db: DatabaseConnection ): Promise<{ outgoing_internal: NoteLinkRow[]; outgoing_external: ExternalLinkRow[]; incoming: NoteLinkRow[]; }> { // Get outgoing internal links const outgoing_internal = await db.all<NoteLinkRow>( `SELECT * FROM note_links WHERE source_note_id = ? ORDER BY line_number`, [noteId] ); // Get outgoing external links const outgoing_external = await db.all<ExternalLinkRow>( `SELECT * FROM external_links WHERE note_id = ? ORDER BY line_number`, [noteId] ); // Get incoming internal links const incoming = await db.all<NoteLinkRow>( `SELECT * FROM note_links WHERE target_note_id = ? ORDER BY created DESC`, [noteId] ); return { outgoing_internal, outgoing_external, incoming }; }

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