Skip to main content
Glama
RadonX
by RadonX

get_note

Retrieve specific note details from your TriliumNext knowledge base using its unique ID to access stored information.

Instructions

Get details of a specific note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteIdYesThe ID of the note to retrieve

Implementation Reference

  • The core handler function implementing the 'get_note' tool logic. Validates input noteId, fetches note metadata and content from Trilium API using parallel requests, processes and structures the response data (including truncated previews for long content), logs activities, and handles various error cases (validation, 404, API errors, unknown) with structured JSON error 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, }; } }
  • MCP tool schema definition for 'get_note' in the ListTools response, specifying the input schema requiring a 'noteId' string.
    { 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 of the 'get_note' tool handler in the MCP CallToolRequestSchema switch statement, dispatching to the class's getNote method.
    case 'get_note': return await this.getNote(request.params.arguments);
  • src/index.js:209-210 (registration)
    Wrapper method in the server class that invokes the actual getNote tool implementation, passing the TriliumClient instance.
    async getNote(args) { return await getNote(this.triliumClient, args);
  • Input validation for noteId using shared validators utility, ensuring it's a valid non-empty string.
    const noteId = validators.noteId(args.noteId);

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