Skip to main content
Glama
RadonX
by RadonX

get_note

Retrieve detailed information about a specific note from your TriliumNext knowledge base by providing its unique note ID.

Instructions

Get details of a specific note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteIdYesThe ID of the note to retrieve

Implementation Reference

  • The primary handler function for the 'get_note' tool. Validates the input noteId, retrieves note metadata and content from the Trilium API, constructs a structured JSON response with note details (including truncated content preview), and handles validation, API, and other errors with appropriate responses.
    export async function getNote(triliumClient, args) { try { // Validate inputs const noteId = validators.noteId(args.noteId); logger.debug(`Getting note: noteId="${noteId}"`); // Get note metadata and content from TriliumNext API const [note, content] = await Promise.all([ triliumClient.get(`notes/${noteId}`), triliumClient.get(`notes/${noteId}/content`) ]); if (!note) { throw new TriliumAPIError('Note not found', 404); } logger.info(`Retrieved note: ${note.title || 'Untitled'} (${noteId})`); // Prepare structured response data const noteData = { operation: 'get_note', timestamp: new Date().toISOString(), note: { noteId, title: note.title || 'Untitled', type: note.type || 'text', mime: note.mime, isProtected: note.isProtected || false, isDeleted: note.isDeleted || false, dateCreated: note.dateCreated, dateModified: note.dateModified, utcDateCreated: note.utcDateCreated, utcDateModified: note.utcDateModified, parentNoteIds: note.parentNoteIds || [], childNoteIds: note.childNoteIds || [], attributes: note.attributes || [], content: { type: typeof content === 'string' ? 'text' : 'binary', length: typeof content === 'string' ? content.length : 0, ...(typeof content === 'string' && content.length <= 10000 && { data: content }), ...(typeof content === 'string' && content.length > 10000 && { preview: content.substring(0, 1000) + '...', truncated: true, fullLength: content.length }) }, triliumUrl: `trilium://note/${noteId}` } }; // Create concise summary const summary = `Note: "${note.title || 'Untitled'}" (${note.type || 'text'}, ${typeof content === 'string' ? content.length + ' chars' : 'binary'})`; return { content: [ { type: 'text', text: summary }, { type: 'application/json', text: JSON.stringify(noteData, null, 2) } ], }; } catch (error) { logger.error(`Failed to get note: ${error.message}`); // Create structured error response const errorData = { operation: 'get_note', timestamp: new Date().toISOString(), request: { noteId: args.noteId }, error: { type: error.constructor.name, message: error.message, ...(error instanceof TriliumAPIError && { status: error.status }), ...(error instanceof TriliumAPIError && error.details && { details: error.details }) } }; if (error instanceof ValidationError) { return { content: [ { type: 'text', text: `Validation error: ${error.message}` }, { type: 'application/json', text: JSON.stringify(errorData, null, 2) } ], isError: true, }; } if (error instanceof TriliumAPIError) { if (error.status === 404) { return { content: [ { type: 'text', text: `Note not found: ${args.noteId}` }, { type: 'application/json', text: JSON.stringify(errorData, null, 2) } ], isError: true, }; } return { content: [ { type: 'text', text: `TriliumNext API error: ${error.message}` }, { type: 'application/json', text: JSON.stringify(errorData, null, 2) } ], isError: true, }; } // Unknown error return { content: [ { type: 'text', text: `Failed to get note: ${error.message}` }, { type: 'application/json', text: JSON.stringify(errorData, null, 2) } ], isError: true, }; } }
  • The input schema for the 'get_note' tool as returned by the ListTools handler, defining the required 'noteId' string parameter.
    { name: 'get_note', description: 'Get details of a specific note', inputSchema: { type: 'object', properties: { noteId: { type: 'string', description: 'The ID of the note to retrieve', }, }, required: ['noteId'], }, },
  • src/index.js:148-149 (registration)
    Registration in the CallToolRequestSchema handler: switch case that routes 'get_note' calls to the getNote wrapper method.
    case 'get_note': return await this.getNote(request.params.arguments);
  • src/index.js:209-211 (registration)
    Wrapper method in the main server class that invokes the actual getNote handler from tools/get-note.js, passing the Trilium client.
    async getNote(args) { return await getNote(this.triliumClient, args); }
  • src/index.js:18-18 (registration)
    Import statement that brings the getNote handler into the main index.js file.
    import { getNote } from './tools/get-note.js';

Other Tools

Related 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/RadonX/mcp-trilium'

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