Skip to main content
Glama

get_backlinks

Identify and retrieve all notes that link to a specified note using the Flint Note system, enabling efficient tracking of references and connections within your markdown-based note vault.

Instructions

Get all notes that link to the specified note

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

  • The MCP tool handler for 'get_backlinks'. Validates arguments, resolves vault and database, checks note existence, retrieves backlinks via LinkExtractor, and returns formatted JSON 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 }; } };
  • JSON Schema definition for the 'get_backlinks' tool input validation, specifying parameters and requirements.
    { 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)' }, vault_id: { type: 'string', description: 'Optional vault ID to operate on. If not provided, uses the current active vault.' } }, required: ['identifier'] } },
  • Core utility method that executes the SQL query to fetch all backlinks (incoming links) for a given note ID from the note_links table.
    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] ); }
  • Detailed validation rules and custom validators for the 'get_backlinks' tool input parameters.
    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