Skip to main content
Glama
tan-yong-sheng

TriliumNext Notes' MCP Server

manage_attributes

Create, update, or delete note attributes like labels (#tags) and relations (~connections) to organize metadata and define relationships between notes in TriliumNext.

Instructions

Manage note attributes with write operations (create, update, delete). Create labels (#tags), template relations (~template), update existing attributes, and organize notes with metadata. IMPORTANT: This tool only provides write access - use read_attributes to view existing attributes. Relations require values pointing to existing notes (e.g., template relations use 'Board', 'Calendar'; author relations use target note titles or IDs). UPDATE LIMITATIONS: For labels, only value and position can be updated. For relations, only position can be updated. The isInheritable property cannot be changed via update - delete and recreate to modify inheritability. Supports single operations and efficient batch creation for better performance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteIdYesID of the note to manage attributes for
operationYesOperation type: 'create' (new attribute), 'update' (modify existing - limited to label value/position and relation position only), 'delete' (remove attribute), 'batch_create' (multiple new attributes efficiently)
attributesNoArray of attributes to create/update/delete. Required for all write operations. IMPORTANT: Update operations have limitations - only label values/positions and relation positions can be updated. To change isInheritable or other properties, delete and recreate the attribute.

Implementation Reference

  • Primary MCP tool handler for 'manage_attributes'. Validates inputs (noteId, operation, attributes), checks WRITE permission, constructs params, invokes core manage_attributes function from attributeManager, formats success/error responses with structured content blocks including emojis and details.
    export async function handleManageAttributes(
      args: ManageAttributesRequest,
      axiosInstance: AxiosInstance,
      permissionChecker: PermissionChecker
    ): Promise<any> {
      try {
        // Validate required parameters
        if (!args.noteId) {
          return {
            content: [
              {
                type: "text",
                text: "❌ Missing required parameter: noteId"
              }
            ],
            isError: true
          };
        }
    
        if (!args.operation) {
          return {
            content: [
              {
                type: "text",
                text: "❌ Missing required parameter: operation"
              }
            ],
            isError: true
          };
        }
    
        // Check WRITE permission for all manage_attributes operations
        if (!permissionChecker.hasPermission("WRITE")) {
          throw new McpError(ErrorCode.InvalidRequest, "Permission denied: Not authorized to manage attributes.");
        }
    
        // Validate operation
        const validOperations = ["create", "update", "delete", "batch_create"];
        if (!validOperations.includes(args.operation)) {
          return {
            content: [
              {
                type: "text",
                text: `❌ Invalid operation: ${args.operation}. Valid operations are: ${validOperations.join(", ")}`
              }
            ],
            isError: true
          };
        }
    
        // Validate attributes for write operations
        if (!args.attributes || !Array.isArray(args.attributes) || args.attributes.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: "❌ Missing or invalid required parameter: attributes (must be a non-empty array for write operations)"
              }
            ],
            isError: true
          };
        }
    
        // For single operations, ensure only one attribute
        if (["create", "update", "delete"].includes(args.operation) && args.attributes.length !== 1) {
          return {
            content: [
              {
                type: "text",
                text: `❌ Operation '${args.operation}' requires exactly one attribute, but ${args.attributes.length} were provided`
              }
            ],
            isError: true
          };
        }
    
        // Execute the attribute operation
        const params: ManageAttributesParams = {
          noteId: args.noteId,
          operation: args.operation as "create" | "update" | "delete" | "batch_create",
          attributes: args.attributes
        };
    
        const result = await manage_attributes(params, axiosInstance);
        return format_attribute_response(result, args.noteId, args.operation);
    
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `❌ Attribute operation failed: ${error instanceof Error ? error.message : 'Unknown error'}`
            }
          ],
          isError: true
        };
      }
    }
  • Defines the tool registration object for 'manage_attributes', including name, description, and full inputSchema (JSON Schema with properties: noteId, operation (create/update/delete/batch_create), attributes array with type/name/value/position/isInheritable). Returned conditionally in generateTools() if WRITE permission.
    export function createWriteAttributeTools(): any[] {
      return [
        {
          name: "manage_attributes",
          description: "Manage note attributes with write operations (create, update, delete). Create labels (#tags), template relations (~template), update existing attributes, and organize notes with metadata. IMPORTANT: This tool only provides write access - use read_attributes to view existing attributes. Relations require values pointing to existing notes (e.g., template relations use 'Board', 'Calendar'; author relations use target note titles or IDs). UPDATE LIMITATIONS: For labels, only value and position can be updated. For relations, only position can be updated. The isInheritable property cannot be changed via update - delete and recreate to modify inheritability. Supports single operations and efficient batch creation for better performance.",
          inputSchema: {
            type: "object",
            properties: {
              noteId: {
                type: "string",
                description: "ID of the note to manage attributes for"
              },
              operation: {
                type: "string",
                enum: ["create", "update", "delete", "batch_create"],
                description: "Operation type: 'create' (new attribute), 'update' (modify existing - limited to label value/position and relation position only), 'delete' (remove attribute), 'batch_create' (multiple new attributes efficiently)"
              },
              attributes: {
                type: "array",
                description: "Array of attributes to create/update/delete. Required for all write operations. IMPORTANT: Update operations have limitations - only label values/positions and relation positions can be updated. To change isInheritable or other properties, delete and recreate the attribute.",
                items: {
                  type: "object",
                  properties: {
                    type: {
                      type: "string",
                      enum: ["label", "relation"],
                      description: "Attribute type: 'label' for #tags (categories, metadata), 'relation' for ~connections (template, author, etc.)"
                    },
                    name: {
                      type: "string",
                      description: "Attribute name: for labels use descriptive tags like 'status', 'priority', 'project'; for relations use connection types that define relationships between notes (e.g., 'template' for built-in templates, 'author' for content creators, 'publisher' for publications). Relations connect notes and always require a target note value."
                    },
                    value: {
                      type: "string",
                      description: "Attribute value: REQUIRED for relations (relations must point to existing notes - use template names like 'Board', 'Calendar', 'Text Snippet' or target note IDs/titles like 'Tolkien' or 'abc123def'), optional for labels (e.g., status labels like 'In Progress', priority labels like 'High'). Relations always need values since they connect notes together."
                    },
                    position: {
                      type: "number",
                      description: "Display position (lower numbers appear first, default: 10)",
                      default: 10
                    },
                    isInheritable: {
                      type: "boolean",
                      description: "Whether attribute is inherited by child notes (default: false). NOTE: This property cannot be changed via update operations. To modify inheritability, delete and recreate the attribute.",
                      default: false
                    }
                  },
                  required: ["type", "name"]
                }
              }
            },
            required: ["noteId", "operation"],
            dependencies: {
              operation: {
                oneOf: [
                  {
                    properties: {
                      operation: { enum: ["create", "update", "delete"] },
                      attributes: { minItems: 1, maxItems: 1 }
                    }
                  },
                  {
                    properties: {
                      operation: { enum: ["batch_create"] },
                      attributes: { minItems: 1 }
                    }
                  }
                ]
              }
            }
          }
        }
      ];
    }
  • Zod schema for validating manage_attributes request parameters, used potentially in validation pipelines (includes attributeSchema for nested validation). Note: enum includes 'read' not in tool.
    export const manageAttributesSchema = z.object({
      noteId: z.string().min(1, 'Note ID cannot be empty'),
      operation: z.enum(['create', 'update', 'delete', 'batch_create', 'read']),
      attributes: z.array(attributeSchema).optional()
    });
  • Core helper function implementing the attribute CRUD logic. Dispatches to specific create/update/delete/batch_create functions that interact with Trilium ETAPI (/attributes POST/PATCH/DELETE), handles validation, parallel batch ops, finds attributes by name/type for update/delete.
    export async function manage_attributes(
      params: ManageAttributesParams,
      axiosInstance: AxiosInstance
    ): Promise<AttributeOperationResult> {
      try {
        switch (params.operation) {
          case "create":
            return await create_single_attribute(params.noteId, params.attributes[0], axiosInstance);
    
          case "batch_create":
            return await create_batch_attributes(params.noteId, params.attributes, axiosInstance);
    
          case "update":
            return await update_attribute(params.noteId, params.attributes[0], axiosInstance);
    
          case "delete":
            return await delete_attribute(params.noteId, params.attributes[0], axiosInstance);
    
          default:
            return {
              success: false,
              message: `Unsupported operation: ${params.operation}`,
              errors: [`Operation ${params.operation} is not supported`]
            };
        }
      } catch (error) {
        return {
          success: false,
          message: `Attribute operation failed: ${error instanceof Error ? error.message : 'Unknown error'}`,
          errors: [error instanceof Error ? error.message : 'Unknown error']
        };
      }
    }
  • src/index.ts:77-83 (registration)
    MCP server ListTools handler that dynamically generates tool list including manage_attributes via generateTools(), which includes createWriteAttributeTools() based on permissions.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      // Generate standard tools based on permissions
      const tools = generateTools(this);
    
    
      return { tools };
    });
  • Central dispatch switch in CallToolRequest handler routes 'manage_attributes' calls to handleManageAttributes.
    case "manage_attributes":
      return await handleManageAttributes(request.params.arguments as any, this.axiosInstance, this);
Behavior5/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 and does so comprehensively. It reveals critical behavioral traits: write-only access, update limitations (only label value/position and relation position can be updated), the immutable nature of isInheritable property, requirements for relation values (must point to existing notes), and performance considerations for batch operations. This goes well beyond what the input schema provides about constraints.

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 appropriately sized and front-loaded with the core purpose and key limitation (write-only access). Each sentence adds value: distinguishing from read operations, explaining attribute types, detailing update limitations, and mentioning performance benefits. While comprehensive, it remains focused without unnecessary repetition or fluff.

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

Completeness4/5

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

For a complex mutation tool with 3 parameters, 100% schema coverage, but no annotations or output schema, the description provides substantial context about behavioral constraints, usage patterns, and limitations. It covers the tool's scope, update restrictions, relation requirements, and performance considerations. The main gap is the lack of information about return values or error conditions, but given the comprehensive behavioral disclosure, this is a minor omission.

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

Parameters4/5

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

The schema description coverage is 100%, so the baseline is 3. The description adds meaningful context about parameter usage: it explains the purpose of different attribute types (labels for #tags, relations for ~connections), provides concrete examples of name values ('status', 'priority', 'template', 'author'), and clarifies value requirements for relations. However, it doesn't add significant semantic information beyond what's already well-documented in the schema descriptions.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('manage', 'create', 'update', 'delete') and resources ('note attributes'), and distinguishes it from the sibling tool 'read_attributes' by explicitly stating this is for write operations only. The description provides concrete examples of what can be managed (labels, template relations) and how they're used.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: it states 'use read_attributes to view existing attributes' and mentions 'efficient batch creation for better performance' as a performance consideration. It also specifies that this tool 'only provides write access,' clearly delineating its scope from read operations.

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/tan-yong-sheng/triliumnext-mcp'

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