Skip to main content
Glama

get_backlinks

Retrieve all notes that link to a specified note in your Flint Note vault. Identify backlinks to understand connections between your notes.

Instructions

Get all notes that link to the specified note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYesNote identifier (type/filename format)

Implementation Reference

  • Main handler method for the get_backlinks tool. Validates input, resolves database context, verifies note existence, queries backlinks using LinkExtractor, and returns JSON-formatted response.
    handleGetBacklinks = async (args: { identifier: string; vault_id?: string }) => { try { // Validate arguments validateToolArgs('get_backlinks', 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 backlinks = await LinkExtractor.getBacklinks(noteId, db); return { content: [ { type: 'text', text: JSON.stringify( { success: true, note_id: noteId, backlinks: backlinks }, 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 the MCP CallToolRequestSchema handler switch statement, dispatching to LinkHandlers.handleGetBacklinks.
    return await this.linkHandlers.handleGetBacklinks( args as unknown as { identifier: string; vault_id?: string } );
  • Tool schema definition returned by ListToolsRequestSchema, specifying input requirements (identifier required).
    name: 'get_backlinks', description: 'Get all notes that link to the specified note', inputSchema: { type: 'object', properties: { identifier: { type: 'string', description: 'Note identifier (type/filename format)' } }, required: ['identifier'] } },
  • Core helper method that executes the SQL query to fetch all incoming links (backlinks) from the note_links table for the given note ID.
    static async getBacklinks( noteId: string, db: DatabaseConnection ): Promise<NoteLinkRow[]> { return await db.all<NoteLinkRow>( `SELECT * FROM note_links WHERE target_note_id = ? ORDER BY created DESC`, [noteId] ); }
  • Input validation rules for get_backlinks tool arguments, ensuring identifier is in 'type/filename' format.
    get_backlinks: [ { field: 'identifier', required: true, type: 'string', allowEmpty: false, customValidator: (value: string) => { 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 } ],

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