Skip to main content
Glama
RadonX

MCP TriliumNext

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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves note details, implying a read-only operation, but doesn't cover aspects like error handling (e.g., what happens if the noteId is invalid), authentication needs, rate limits, or return format, which are critical for an agent to use it correctly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence: 'Get details of a specific note'. It's appropriately sized and front-loaded, with no wasted words, making it efficient. However, it could be slightly more structured by including key details upfront, but it's concise enough to earn a high score.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a read operation with one parameter) and the absence of annotations and output schema, the description is incomplete. It doesn't explain what 'details' are returned, error scenarios, or how it differs from siblings, leaving gaps that could hinder an agent's ability to use the tool effectively without additional context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with 'noteId' clearly documented as 'The ID of the note to retrieve'. The description adds no additional meaning beyond this, as it doesn't explain parameter usage or constraints. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get details of a specific note' clearly states the verb 'Get' and resource 'note', making the purpose understandable. However, it lacks specificity about what 'details' include and doesn't distinguish from sibling tools like 'search_notes' or 'create_note', which is a missed opportunity for clarity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention that 'get_note' is for retrieving a single note by ID, while 'search_notes' might be for multiple notes or filtering, leaving the agent to infer usage from context without explicit help.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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