Skip to main content
Glama
triliumnext-mcp

triliumnext-mcp

by perfectra1n

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
LOG_LEVELNoLog level: silent, error, warn, info, debuginfo
LOG_FORMATNoLog format: text or jsontext
TRILIUM_URLNoTrilium ETAPI URLhttp://localhost:37740/etapi
TRILIUM_TOKENNoTrilium ETAPI token (required in single-tenant mode)
TRILIUM_METRICSNoEnable Prometheus metrics endpointfalse
TRILIUM_HTTP_PORTNoHTTP server port when using http transport3000
TRILIUM_TRANSPORTNoTransport type: stdio or httpstdio
TRILIUM_JWT_ISSUERNoExpected JWT issuer
TRILIUM_JWT_SECRETSNoComma-separated JWT shared secrets (HS256)
TRILIUM_CORS_ORIGINSNoComma-separated allowed CORS origins
TRILIUM_GATEWAY_AUTHNoGateway auth mode: none, bearer, or jwtbearer
TRILIUM_JWT_AUDIENCENoExpected JWT audience
TRILIUM_JWT_JWKS_URLNoJWKS URL for RS256/ES256/EdDSA
TRILIUM_METRICS_AUTHNoMetrics auth mode: gateway, bearer, or nonegateway
TRILIUM_MULTI_TENANTNoEnable multi-tenant modefalse
TRILIUM_URL_ALLOWLISTNoComma-separated allowed hostnames for client URLs
TRILIUM_GATEWAY_TOKENSNoComma-separated list of accepted bearer tokens
TRILIUM_MAX_POST_BYTESNoMax size of a single MCP JSON-RPC POST body on the SSE transport500mb
TRILIUM_METRICS_TOKENSNoComma-separated tokens for metrics bearer auth
TRILIUM_RATE_LIMIT_RPSNoRate limit requests per second
TRILIUM_RATE_LIMIT_BURSTNoRate limit burst size
TRILIUM_ALLOW_PRIVATE_URLSNoSkip private/loopback IP SSRF blockfalse
TRILIUM_JWT_PRINCIPAL_CLAIMNoJWT claim to use as principal (default: sub)

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server manages a TriliumNext notes tree.

Searching

search_notes defaults to strategy "auto": a plain-word query first matches titles and labels (fast) and searches note bodies only when that finds too few notes. A body search can take a long time on a large Trilium and blocks it meanwhile, so use strategy "full" only when the words may appear only inside note text. If a call fails with TRILIUM_BUSY, wait the suggested time instead of retrying at once.

Working with notes

  • Get note, branch and attribute IDs from search_notes, get_note_tree or get_note; never guess them.

  • Explore with search_notes and get_note_tree before creating or moving notes, and confirm the parent with the user when unsure.

  • Read content through these tools (get_note, get_attachment, get_revisions), not raw ETAPI/HTTP calls.

  • write_note edits (changes/patch) match the stored HTML, not rendered text: read with get_note format="html" first and copy exact substrings.

  • manage_system export returns a ZIP for the user to save; you cannot read its contents. Use get_note to read notes.

  • Before rewriting a note wholesale, call create_revision (restore_revision also snapshots automatically) so the change can be undone.

  • When a tool returns a url, give it to the user so they can open the note directly.

Note types that need extra setup

Choose type (and mime) on create_note. These types do nothing until you also add attributes with set_attribute (name without the leading # or ~):

  • code: set mime, e.g. "text/x-python". For scripts use "application/javascript;env=frontend" (runs in the UI) or "application/javascript;env=backend" (runs on the server). A script runs only when triggered: add label run = "frontendStartup", "backendStartup", "hourly", "daily", …; a backend script can serve HTTP via label customRequestHandler.

  • render: mime empty. Create a frontend code note that builds the HTML, then add relation renderNote → that code note on the render note.

  • Custom widget: a frontend code note that returns a widget, plus label widget with value "".

  • canvas and mindMap: mime = "application/json". mermaid: content is the diagram source. geoMap: coordinates live in child-note labels.

Linking notes

Link to another note with text (markdown: text) in create_note/write_note content; the server builds the Trilium reference link. Use get_note include_path=true to tell the user where a note lives, and include_backlinks=true to find what links to it.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
search_notesA

Find notes by full-text and/or attribute filters (Trilium search syntax). Returns metadata only (noteId, title, type, mime, dateModified, parentNoteIds, attributes); read bodies with get_note, or set content_preview_chars for short previews.

Syntax:

  • rings tolkien — all words must appear (AND); "exact phrase" for phrases.

  • #label, #!label (without), #year >= 1950, #name *=* john, ~relation; combine with fulltext by spaces (AND).

  • Operators: = != = (contains) =* (starts) *= (ends) %= (regex) >= > < <=. Group with parentheses and AND/OR, e.g. (#year >= 1950 AND #year <= 1960), #book or #article.

  • a or b between plain words is rewritten to match note content only (not titles); for titles use title:a or title:b.

  • title:weekly meeting — title contains the text (auto-quoted; trailing #label/~relation filters still apply).

  • id:abc123 — direct lookup by note ID. A lone 12-character alphanumeric token containing a digit is also tried as an ID first.

  • Properties: note.title, note.dateCreated, note.dateModified, note.parents.title, note.ancestors.title.

Scope a subtree with ancestorNoteId + ancestorDepth. If a plain multi-word query finds nothing, it is retried as a ranked OR (see fuzzy); the response then has searchMode:"fuzzy" and termsMatchedInTitleOrAttributes. partial:true means part of the search did not finish; read the note field.

get_note_treeA

Explore the note hierarchy from a note, expanding children "depth" levels (default 1). Each node has noteId, title, type, childCount and childBranchIds; expanded children also carry their own branchId (what organize_note reorder/unlink need). Nodes at the depth boundary list childNoteIds for a follow-up call. System notes (IDs starting with "_") are skipped unless you start from one. At most 200 notes per call; the response is marked truncated when the cap is hit.

get_noteA

Read a note. Returns a metadata JSON block (title, type, attributes, parent/child IDs, and contentInfo with the total size and returned character range), then the body (stored HTML by default), then any images embedded in the body. Bodies over 50000 characters are paged via content_start/content_max_chars. Pass include_content=false for metadata only, include_path=true for breadcrumbs of where the note lives, include_backlinks=true for notes linking to it (a slow scan of all note bodies).

get_note_historyA

Get recent changes across the note tree — creations, modifications, and deletions. Optionally filter by subtree via ancestorNoteId. Returns {changes, total, returned, truncated}; pass limit (default 100) to see more. Distinct from revisions: this is a change log across notes; revisions are content snapshots of a single note.

create_noteA

Create a note under an existing parent and return the note, its branch and a url. Pick the parent with search_notes/get_note_tree; use "root" only for genuinely top-level notes. Text content is HTML or markdown (format="markdown"). Images/files can be uploaded and embedded in the same call (see the images/files fields). Give the user the returned url.

write_noteA

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.

delete_noteA

Delete (soft) or restore a note. Deleting removes the note and every child that has no other parent; clones elsewhere survive. Restore with action="undelete".

get_revisionsA

Read note revisions (content snapshots of one note). Pass noteId to list its revisions (metadata: revisionId, title, type, dates, content length), or revisionId to read one revision's body (file/image revisions return metadata only). For a change log across many notes use get_note_history instead.

restore_revisionA

Restore a note to one of its revisions: writes the revision's content (and, by default, title) back onto the live note. By default the current state is snapshotted first with create_revision, so the restore is reversible. Find revision IDs with get_revisions {noteId}; preview one with get_revisions {revisionId}. Protected notes cannot be restored through ETAPI.

get_attributesA

Read attributes. Pass noteId for the note's own labels and relations (inherited attributes are not included), or attributeId for one attribute. Exactly one is required.

set_attributeA

Add or update a label or relation on a note. Upsert (default) edits the first own attribute with the same type+name in place when only a label's value or the position changes. Trilium cannot edit a relation's target or isInheritable in place, so those changes delete and recreate the attribute; the response then has replaced:true, oldAttributeId and the new attributeId.

delete_attributeB

Remove an attribute from a note by its attribute ID.

get_attachmentA

Read one attachment (attachmentId) or list a note's attachments (noteId, metadata only). Bodies come back by type: images as image blocks, text as a string (long text is truncated), other binaries as a base64 embedded resource. Images and binaries over 5 MB return metadata only.

create_attachmentA

Attach content to a note and return the attachment metadata. mime and title are auto-detected from the source (a path or URL basename becomes the title); inline base64/text needs a title. Example: {ownerId, role: "image", title: "dot.png", content: "data:image/png;base64,iVBORw0..."}.

write_attachmentA

Update an attachment: mode="metadata" changes role/mime/title/position; "replace" overwrites the body (path, URL, data URL, base64 or text; the stored mime is kept); "edit" applies "changes" or a "patch" to a text attachment (binary attachments must use "replace").

delete_attachmentB

Permanently delete an attachment and its content.

get_special_noteA

Get (creating if missing) a day/week/month/year journal note, the inbox note, or the first day of a week. Returns the note metadata; read its body with get_note.

organize_noteA

Reorganize the note tree. Actions:

  • "move": place the note under newParentNoteId and remove its old placement (the new branch is created first). If the note has several placements other than newParentNoteId, fromParentNoteId must say which to remove. If newParentNoteId is already a parent: with no other placement nothing changes; with exactly one other placement, that one is REMOVED (the note collapses onto newParentNoteId) — use "clone" instead to keep both.

  • "clone": add a placement under parentNoteId without removing any (same note, new branch).

  • "reorder": set notePosition on child branches of parentNoteId; every branch must belong to it.

  • "unlink": remove one branch. If it is the note's last branch, the note itself is deleted. Branch IDs come from get_note (parentBranchIds/childBranchIds) or get_note_tree (childBranchIds, children[].branchId). move and clone return the url of the note at its new location.

create_revisionA

Snapshot a note's current content as a revision so later edits can be undone. List and read revisions with get_revisions; roll back with restore_revision.

manage_systemA

Trilium system operations, selected by "action":

  • "app_info" (read-only): Trilium app/database/clipper versions.

  • "metrics" (read-only): note, attachment, revision, branch and attribute counts and per-type breakdowns. Needs a Trilium version with /etapi/metrics.

  • "backup": write backup-.db to Trilium's data directory, replacing a backup with the same name.

  • "export": export a subtree as a ZIP (html, markdown or share format), returned as an embedded resource for the user to save (max 10 MB). You cannot read the ZIP contents — to read notes use get_note.

  • "import": import a base64 ZIP (e.g. a previous export) under noteId; returns the created note.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.9/5.0

Scored across 20 tools

Disambiguation4/5

Each tool has a clearly stated resource+action, and the descriptions explicitly disambiguate the riskiest pairs (get_note_history vs get_revisions, create_note vs write_note, delete_note vs delete_attribute). The only blur comes from multi-action tools (manage_system's five actions, organize_note's move/clone/reorder/unlink) and the dual read/list role of get_attachment, which an agent must resolve via parameters rather than tool choice.

Naming Consistency4/5

Nearly all names follow a clean snake_case verb_noun pattern (search_notes, get_note_tree, create_attachment, delete_attribute). The minor deviation is the mix of create_/write_/set_ for mutation operations plus the vague verb in manage_system, but these distinctions are semantically meaningful and documented rather than arbitrary.

Tool Count4/5

At 20 tools it sits at the heavy end, but the domain genuinely spans notes, tree branches, attributes, attachments, revisions, journal/inbox notes, and system operations, so each tool maps to a real capability. It would be slightly cleaner if some read-mode tools were split or consolidated, but nothing is obviously redundant.

Completeness5/5

Full lifecycle coverage across every entity: notes (search/read/create/write/soft-delete/restore), tree organization (move/clone/reorder/unlink), attributes CRUD, attachments CRUD, revisions (create/list/read/restore), a cross-note change log, special notes, and system export/import/backup/metrics. Remaining gaps (no hard delete, no revision deletion, ZIP contents unreadable) reflect underlying Trilium API limits and are explicitly documented so agents don't dead-end.

Maintenance

ActivityActive
ResponsivenessLimited data