Skip to main content
Glama
triliumnext-mcp

triliumnext-mcp

by perfectra1n

Write note

write_note
Destructive

Modifies an existing TriliumNext note: update metadata, replace or append content, apply search/replace edits, and embed uploaded images or files.

Instructions

Change an existing note. mode="metadata" updates title/type/mime/dates; "replace" overwrites the content; "append" adds to the end; "edit" applies search/replace "changes" (preferred) or a unified diff "patch" to the stored HTML — read it with get_note format="html" first. replace/append can also upload and embed images/files. Give the user the returned url.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "noteId": "<noteId>",
      "mode": "<mode>"
    },
    "name": "write_note"
  }
}

Input Schema

NameRequiredDescriptionDefault
mimeNoNew MIME type (metadata mode only). For runnable scripts use application/javascript;env=frontend or application/javascript;env=backend; see the server instructions for the attribute wiring.
modeYesWrite mode. "metadata" — update title/type/mime/dates only (no content change). "replace" — overwrite the entire content with the provided content. "append" — add the provided content at the end of the existing content (text/code notes). "edit" — apply search/replace blocks (changes) or a unified diff (patch) to the existing content.
typeNoNew type (metadata mode only)
filesNoFiles to upload as attachments of this note and link as downloads. Reference entry N with <a href="file:N">label</a> (HTML, double quotes) or [label](file:N) (markdown); same indexing rules as images. Unreferenced files are appended as download links. To link an existing attachment use <a href="api/attachments/{attachmentId}/download">label</a>.
patchNo"edit" mode: a single-file unified diff (with @@ hunks) against the stored content. Trilium HTML is often one long line, so prefer "changes".
titleNoNew title (metadata mode only)
formatNo"markdown" converts content to HTML before saving ("replace"/"append" only). Applies to text notes only; ignored for other types.html
imagesNoImages to upload as attachments of this note and embed. Reference entry N from the content with <img src="image:N"> (HTML, double quotes) or ![alt](image:N) (markdown); N indexes THIS array only, not attachments from earlier calls. Unreferenced images are appended at the end; an unresolved placeholder fails the call. To embed an existing attachment use its real URL: <img src="api/attachments/{attachmentId}/image/{filename}">. Images and files together may total at most the server's per-input content limit; add more with create_attachment.
noteIdYesID of the note to write to
changesNo"edit" mode: search/replace blocks applied in order to the STORED content — HTML for text notes, so read it with get_note format="html" first (markdown from get_note will not match). Each old_string must match exactly once; include surrounding context to make it unique. An empty old_string inserts new_string at the start.
contentNoNew content for "replace"/"append". Same conventions as create_note content (HTML or markdown, note:<id> links); for binary (file/image) notes "replace" takes a path, URL, data URL or base64.
dateCreatedNoNew local creation date (metadata mode only). Format: "2024-01-15 10:30:00.000+0100"
utcDateCreatedNoNew UTC creation date (metadata mode only). Format: "2024-01-15 09:30:00.000Z"
utcDateModifiedNoNew UTC last-modified date (metadata mode only), e.g. to restore a migrated note's original date after rewriting its content. Format: "2024-01-15 09:30:00.000Z". Needs a Trilium newer than 0.105.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed19 schema fields changedv0.4.0
    • changedInput schema / properties / changes / description
      Previous value: -"\"edit\" mode: array of search/replace blocks applied sequentially. Each block has old_string (exact match) and new_string (replacement). Operates on stored content (HTML for text notes)."New value: +"\"edit\" mode: search/replace blocks applied in order to the STORED content — HTML for text notes, so read it with get_note format=\"html\" first (markdown from get_note will not match). Each old_string must match exactly once; include surrounding context to make it unique. An empty old_string inserts new_string at the start."
    • changedInput schema / properties / changes / items / properties / new_string / description
      Previous value: -"The replacement string"New value: +"Replacement text (\"\" deletes old_string)"
    • changedInput schema / properties / changes / items / properties / old_string / description
      Previous value: -"The exact string to find in the existing content"New value: +"Exact substring of the stored content; must occur exactly once (\"\" = insert at start)"
    • changedInput schema / properties / content / description
      Previous value: -"New content. Required for \"replace\" and \"append\" modes. For text notes: provide HTML (default) or markdown (if format is \"markdown\"). For code blocks in HTML, use <pre><code class=\"language-X\">...</code></pre> structure. Internal links to other Trilium notes: write <a href=\"note:TARGET_NOTE_ID\">Link text</a> in HTML, or [Link text](note:TARGET_NOTE_ID) in markdown — the server turns it into a proper Trilium reference link (class=\"reference-link\" + href/data-note-path built from the target's tree path) and rejects the write if the target does not exist. Leave the link text empty to use the target's title. Do NOT write [text](#root/...) markdown links or hand-built anchors without class=\"reference-link\" and data-note-path — Trilium stores those as inert hash anchors, not note links."New value: +"New content for \"replace\"/\"append\". Same conventions as create_note content (HTML or markdown, note:<id> links); for binary (file/image) notes \"replace\" takes a path, URL, data URL or base64."
    • changedInput schema / properties / files / description
      Previous value: -"Optional array of files to attach and embed as download links in the note. The data field accepts a local file path, an http(s) URL, a data URL, raw base64 (binary types), or raw text (text types) — auto-detected; mime and filename are optional. Reference files in your content using placeholder URLs: in markdown use [label](file:0), [label](file:1), etc. In HTML use <a href=\"file:0\">label</a> (double quotes required). The number is the zero-based index into THIS array — placeholders do NOT reference attachments uploaded in earlier calls. Files and placeholders must be provided together in the same call. Files without a corresponding placeholder are appended at the end of the content as download links. To reference an attachment you uploaded separately, use its real URL: <a href=\"api/attachments/{attachmentId}/download\">label</a>."New value: +"Files to upload as attachments of this note and link as downloads. Reference entry N with <a href=\"file:N\">label</a> (HTML, double quotes) or [label](file:N) (markdown); same indexing rules as images. Unreferenced files are appended as download links. To link an existing attachment use <a href=\"api/attachments/{attachmentId}/download\">label</a>."
    • changedInput schema / properties / files / items / properties / data / description
      Previous value: -"The file. Pass any of: a local file path (\"/abs/path\" or \"~/path\"), an http(s) URL, a data URL (data:image/png;base64,...), or inline base64 (binary types) / raw text (text types) — the source is auto-detected. Use a file:// prefix to force path interpretation."New value: +"The file, in any of the forms images[].data accepts."
    • changedInput schema / properties / files / items / properties / filename / description
      Previous value: -"Optional filename for the file attachment (e.g., \"report.pdf\"). Defaults to the path/URL basename, else file-N."New value: +"Attachment filename (e.g. \"report.pdf\"). Defaults to the path/URL basename, else file-N."
    • changedInput schema / properties / files / items / properties / mime / description
      Previous value: -"Optional MIME type (e.g., \"application/pdf\", \"text/csv\") — auto-detected from the source; set only to override."New value: +"MIME type override (e.g. \"application/pdf\"); normally auto-detected."
    • addedInput schema / properties / files / maxItems
      Added value: +50
    • changedInput schema / properties / format / description
      Previous value: -"Content format for text notes. Use \"markdown\" to auto-convert markdown to HTML. Defaults to \"html\". Only applies in \"replace\"/\"append\" modes."New value: +"\"markdown\" converts content to HTML before saving (\"replace\"/\"append\" only). Applies to text notes only; ignored for other types."
    • changedInput schema / properties / images / description
      Previous value: -"Optional array of images to embed in the note. The data field accepts a local file path, an http(s) URL, a data URL, or raw base64 — auto-detected; mime and filename are optional. Reference images in your content using placeholder URLs: in markdown use ![alt](image:0), ![alt](image:1), etc. In HTML use <img src=\"image:0\"> (double quotes required). The number is the zero-based index into THIS array — placeholders do NOT reference attachments uploaded in earlier calls. Images and placeholders must be provided together in the same call. Images without a corresponding placeholder are appended at the end of the content. To reference an attachment you uploaded separately, use its real URL: <img src=\"api/attachments/{attachmentId}/image/{filename}\">."New value: +"Images to upload as attachments of this note and embed. Reference entry N from the content with <img src=\"image:N\"> (HTML, double quotes) or ![alt](image:N) (markdown); N indexes THIS array only, not attachments from earlier calls. Unreferenced images are appended at the end; an unresolved placeholder fails the call. To embed an existing attachment use its real URL: <img src=\"api/attachments/{attachmentId}/image/{filename}\">. Images and files together may total at most the server's per-input content limit; add more with create_attachment."
    • changedInput schema / properties / images / items / properties / data / description
      Previous value: -"The image. Pass any of: a local file path (\"/abs/path\" or \"~/path\"), an http(s) URL, a data URL (data:image/png;base64,...), or inline base64 (binary types) / raw text (text types) — the source is auto-detected. Use a file:// prefix to force path interpretation."New value: +"The image. Pass any of: an http(s) URL, a data URL (data:image/png;base64,...), or inline base64 (binary types) / raw text (text types) — the source is auto-detected. A file path (\"/abs/path\", \"~/path\", or file://...) refers to the MCP SERVER's filesystem and only works when the server permits local file reads."
    • changedInput schema / properties / images / items / properties / filename / description
      Previous value: -"Optional filename for the image attachment (e.g., \"screenshot.png\"). Defaults to the path/URL basename, else image-N."New value: +"Attachment filename (e.g. \"chart.png\"). Defaults to the path/URL basename, else image-N."
    • changedInput schema / properties / images / items / properties / mime / description
      Previous value: -"Optional MIME type (e.g., \"image/png\") — auto-detected from the source; set only to override."New value: +"MIME type override (e.g. \"image/png\"); normally auto-detected."
    • addedInput schema / properties / images / maxItems
      Added value: +50
    • changedInput schema / properties / mode / description
      Previous value: -"Write mode. \"metadata\" — update title/type/mime only (no content change). \"replace\" — overwrite the entire content with the provided content. \"append\" — fetch existing content and concatenate the provided content at the end. \"edit\" — apply search/replace blocks (changes) or a unified diff (patch) to the existing content."New value: +"Write mode. \"metadata\" — update title/type/mime/dates only (no content change). \"replace\" — overwrite the entire content with the provided content. \"append\" — add the provided content at the end of the existing content (text/code notes). \"edit\" — apply search/replace blocks (changes) or a unified diff (patch) to the existing content."
    • addedInput schema / properties / noteId / maxLength
      Added value: +128
    • addedInput schema / properties / noteId / pattern
      Added value: +"^[A-Za-z0-9_]+$"
    • changedInput schema / properties / patch / description
      Previous value: -"\"edit\" mode: unified diff to apply to existing content."New value: +"\"edit\" mode: a single-file unified diff (with @@ hunks) against the stored content. Trilium HTML is often one long line, so prefer \"changes\"."
  2. First observedv1.0.0

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true, readOnlyHint=false, and openWorldHint=true; the description adds genuine value beyond them by spelling out overwrite vs append semantics, the pitfall that stored HTML is often one long line (so diff patches are unreliable), and the post-call convention of surfacing the returned url to the user. It does not discuss reversal/versioning of destroyed content, which would push it higher.

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

Conciseness5/5

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

One compact paragraph, front-loaded with the action and mode table, then prerequisites and the upload capability. Every clause carries distinct information; no filler or restatement of the name.

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 14-parameter mutation tool with no output schema, the description covers the decision-critical parts: mode semantics, the required read-before-edit step, upload embedding, and the returned url to report. Remaining gaps (permission requirements, size limits, whether modes can be combined) are either in the schema or secondary.

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?

Schema coverage is 100%, so baseline is 3, but the description adds prioritization the schema does not: search/replace changes are preferred over patch, and replace/append support image/file upload and embedding. It omits mention of the metadata-mode date/mime parameters, which the schema already documents thoroughly.

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?

Opens with a specific verb+resource ("Change an existing note") and immediately enumerates the four modes with their distinct effects, so an agent can tell exactly what the tool does. "Existing note" implicitly distinguishes it from create_note, and get_note is named as the read counterpart.

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

Usage Guidelines4/5

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

Gives per-mode selection guidance, an explicit preference ("edit" applies search/replace "changes" (preferred) or a unified diff "patch"), and a prerequisite ("read it with get_note format=\"html\" first"). It stops short of naming a when-not case or routing new content to create_note, so it is clear context rather than full alternatives coverage.

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