Agent skill

Adding LLM MCP Tools

by TriliumNext in TriliumNext/Trilium

A skill your agent uses when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ —…

AGPL-3.0Auto-check passedTesting & QA

Install Adding LLM MCP Tools

skills CLI
$ npx skills add TriliumNext/Trilium --skill adding-llm-mcp-tools -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install TriliumNext/Trilium adding-llm-mcp-tools --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/TriliumNext/Trilium.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/adding-llm-mcp-tools .claude/skills/adding-llm-mcp-tools && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
adding-llm-mcp-tools
GitHub stars
38k
Token cost
~2.5k tokens
SKILL.md length
1,067 words
Files
2 (incl. references)
Skills in repo
22
Repo updated
First seen
Licence
AGPL-3.0

At a glance

A skill your agent uses when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ —…

  • Works in 7 steps: Pick or create the module… → Give it description (string the LLM… → For writes, add mutates: true (footgun… → …
  • Client-side note UI
  • SKILL.md covers Footgun #1 (the big one):…, Footgun #2: mutates: true is…, Footgun #3: a new module is… and Footgun #4: return { error:…, plus 5 more sections
  • Calls git and pnpm

What it does

Adding LLM MCP Tools is an agent skill from TriliumNext/Trilium. Use when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ — note/attribute/attachment/hierarchy/icon/skill tools) — anything exposed to both the in-app LLM chat and the external MCP server. Covers why execute MUST be synchronous (the NotAPromise<T compile guard + better-sqlite3 sync transactions), the mutates:true→getSql().transactional wiring, the single allToolRegistries registration point feeding both consumers, the…

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/spec-harness.md`).

It sits in Testing & QA, covering MCP servers and Unit testing. It works with Model Context Protocol, SQLite and Vitest. The repository describes itself as: Build your personal knowledge base with Trilium Notes. The licence is AGPL-3.0.

When your agent uses it

  • Client-side note UI
  • ETAPI endpoints
  • Generic Vitest questions (see writing-unit-tests)

Example prompts

  • “/adding-llm-mcp-tools”

Workflow steps

7 steps, taken from the first numbered list in SKILL.md.

  1. Pick or create the module ({note,attribute,attachment,hierarchy,icon,skill}_tools.ts, or a new *_tools.ts). Declare the tool inside…
  2. Give it description (string the LLM reads), inputSchema (z.object({...}) with .describe() on each field), and execute — synchronous…
  3. For writes, add mutates: true (footgun #2).
  4. Guard inputs in order and return { error } on every failure branch (footguns #4, #5); wrap throwing service calls in try/catch.
  5. New module only: register it in allToolRegistries (footgun #3).
  6. Add the client-side friendly name in apps/client/src/translations/en/translation.json under llm.tools., imperative tense ("Create note"…
  7. Write the spec with the getTool() + cls.init() harness — see spec-harness.md.

What it can do on your machine

Read from SKILL.md and the folder at commit cac2b4f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • pnpm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and pnpm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Adding LLM MCP Tools loads about 2.5k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 193 tokens; SKILL.md has 1,067 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~193
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from TriliumNext/Trilium at commit cac2b4f, republished under its AGPL-3.0 licence (© TriliumNext). 1,067 words, ~2,534 tokens.

Download SKILL.mdSave it as .claude/skills/adding-llm-mcp-tools/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
adding-llm-mcp-tools
description
Use when adding, changing, or reviewing an LLM/MCP tool in Trilium (the `defineTools` definitions under packages/trilium-core/src/services/llm/tools/ — note/attribute/attachment/hierarchy/icon/skill tools) — anything exposed to both the in-app LLM chat and the external MCP server. Covers why `execute` MUST be synchronous (the `NotAPromise<T>` compile guard + better-sqlite3 sync transactions), the `mutates:true`→`getSql().transactional` wiring, the single `allToolRegistries` registration point feeding both consumers, the return-`{error}`-don't-throw contract, the protected/system-note guards, and the `getTool()`/`cls.init()` spec harness. Do NOT use for client-side note UI, ETAPI endpoints, or generic Vitest questions (see writing-unit-tests).

Adding an LLM/MCP tool

One tool definition, two consumers. Every tool under packages/trilium-core/src/services/llm/tools/ is declared once via defineTools({...}) and consumed by BOTH the in-app LLM chat AND the external MCP server. The wiring rules below all fall out of that fact — internalize it before touching anything.

Footgun #1 (the big one): execute MUST be synchronous

No async, no await, no returned Promise. This is not a style preference — better-sqlite3 transactions are synchronous, so an async execute lets getSql().transactional() commit before the awaited work runs, silently corrupting entity-change/Becca tracking.

The type system is built to make this a compile error (tool_registry.ts:21,32,40):

ts
type NotAPromise<T> = T & { then?: void };          // line 21
// ...
execute: (args: any) => NotAPromise<object>;        // lines 32 (mutating) & 40 (read-only)

A Promise has then: Function, which violates then?: void → typecheck rejects it. It regressed twice anyway (git show 09be2822e0 "fix(llm): some tools were async", a93029f789 "fix(llm): misuse of transactions in tool use due to async") — the NotAPromise guard is the durable fix. Do not weaken it (no as any, no widening the return type). If you need data, fetch it synchronously through Becca / the sync services; the tools deliberately reuse the same logic as ETAPI without HTTP.

Footgun #2: mutates: true is load-bearing wiring, not a label

Both consumers branch on it to wrap the call in a transaction. Forget it on a write tool and execute runs outside a transaction — no error, just broken entity-change tracking.

  • LLM chat: tool_registry.ts:65-66 — def.mutates ? (args) => getSql().transactional(() => def.execute(args)) : def.execute
  • MCP: mcp_server.ts:29-33 (note: it lives in apps/server/src/services/mcp/, not under llm/) — the same branch, inside its own cls.init

Rule: any tool that writes (setContent, save, setAttribute, createNewNote, branch/clone/move, deleteNote, markAsDeleted) gets mutates: true. Read-only tools omit it (or mutates: false).

Footgun #3: a new module is invisible until registered

allToolRegistries (packages/trilium-core/src/services/llm/tools/index.ts:34) is the single wiring point iterated by both mcp_server.ts:51 and base_provider.ts:389 (llm/providers/base_provider.ts, Object.assign(tools, registry.toToolSet())). Adding a tool to an existing module (e.g. another entry in note_tools.ts) needs no wiring. Creating a new module means: export const xTools = defineTools({...}), add the export/import lines in index.ts, and append xTools to the allToolRegistries array. Miss the array and chat + MCP both never see it.

Node-only tools take the other door. A tool that needs something core cannot have in the browser (the in-app documentation reader, for instance) lives in apps/server/src/services/llm/tools/ (doc_notes.ts, help_tools.ts) and registers at server startup via registerToolRegistryLoader(async () => (await import("./tools/x.js")).xTools) from core's light tools/registration.ts (see registerServerLlmExtensions); the first chat turn or MCP request resolves the loader through resolveToolRegistries() and appends the registry to the same array. Register the loader, never a static import — the loader form is what keeps the tool stack (zod, the AI SDK) out of the server's startup path. Standalone simply runs without it. Put a tool there only if it genuinely cannot run under sqlite-wasm — core is the default home, and anything placed in the server loses the standalone and desktop consumers.

Footgun #4: return { error: "..." } — never throw

The pipeline keys off the literal error property; a thrown exception escapes the contract. Every guard does return { error: "Note not found" } (note_tools.ts:72,87,110). Service calls that can throw are wrapped in try/catch that converts to { error } (see create_note in note_tools.ts):

ts
try {
    const { note } = noteService.createNewNote({ parentNoteId, title, content: htmlContent, type });
    return { success: true, noteId: note.noteId, /* ... */ };
} catch (err) {
    return { error: err instanceof Error ? err.message : "Failed to create note" };
}

Footgun #5: protected / system-note guards are mandatory and ordered

Skipping these lets the LLM corrupt protected or system notes. Apply in this order (see note_tools.ts):

CheckGuardReturns
Note exists!becca.getNote(id){ error: "Note not found" }
Not protected!note.isContentAvailable(){ error: "Note is protected..." }
Right content kind!note.hasStringContent(){ error: "Cannot ... note type: ${note.type}" }
Stored content is texttypeof note.getContent() !== "string"{ error: "Note has binary content" }
Rename/deletenote.isProtected{ error: "...cannot be renamed/deleted" }
Delete/move/clone a system notePROTECTED_SYSTEM_NOTES.has(noteId){ error: "Cannot delete system notes" }

PROTECTED_SYSTEM_NOTES lives in helpers.ts:19 = new Set(["root", "_hidden", "_share", "_lbRoot", "_globalNoteMap"]). For attribute writes, also guard attributeService.isAttributeDangerous(type, name) and (for relations) a missing target note (attribute_tools.ts:75).

Mirror ETAPI's field choices, but never import its mappers. A tool that returns a note should pick the same fields ETAPI's response does, so the two surfaces describe an entity the same way — but inline that mapping in the tool. This used to be a discipline; since the tools moved into packages/trilium-core it is also structural, because ETAPI lives in apps/server/src/etapi/ and core cannot import from an app. If you find yourself wanting a shared mapper, the type belongs in @triliumnext/commons, not in a cross-layer import.

Show full SKILL.md (372 more words)Show less

The recipe (ordered)

  1. Pick or create the module ({note,attribute,attachment,hierarchy,icon,skill}_tools.ts, or a new *_tools.ts). Declare the tool inside defineTools({...}).
  2. Give it description (string the LLM reads), inputSchema (z.object({...}) with .describe() on each field), and execute — synchronous (footgun #1).
  3. For writes, add mutates: true (footgun #2).
  4. Guard inputs in order and return { error } on every failure branch (footguns #4, #5); wrap throwing service calls in try/catch.
  5. New module only: register it in allToolRegistries (footgun #3).
  6. Add the client-side friendly name in apps/client/src/translations/en/translation.json under llm.tools.<tool_name>, imperative tense ("Create note", not "Creating note"). English only — other locales come via Weblate (see CLAUDE.md / translating-locales).
  7. Write the spec with the getTool() + cls.init() harness — see spec-harness.md.

Decision table — guards & test harness per tool shape

Tool does…mutatesRequired guards (in order)Spec harness
read-only (search/get)omit!note → error; isContentAvailable() for content readsplain getTool(name).execute(args); mock search.findResultsWithQuery if it searches
edit existing note contenttrue!note → not found; !isContentAvailable() → protected; !hasStringContent() → bad type; binary getContent() → binaryPattern A: buildNote + stub setContent/saveRevision (no CLS)
create / move / clone (service writes)trueparent !isContentAvailable(); wrap service call in try/catch → { error }Pattern B: cls.init(() => createNewNote(...)) to seed, cls.init(() => getTool(...).execute(...)) to call
rename / deletetruePROTECTED_SYSTEM_NOTES.has(noteId) first; then !note; then note.isProtectedPattern A (mock deleteNote/save) or Pattern B

The two harness patterns are spelled out fully in the reference — don't re-derive the boilerplate.

Quick verification checklist (before you finish)

  • execute is not async and returns no Promise (typecheck rejects it otherwise — run pnpm typecheck).
  • Every write tool has mutates: true.
  • A brand-new module is in allToolRegistries (index.ts:34).
  • All failure branches return { error }; the only throws are service calls wrapped in try/catch.
  • Protected/system-note guards present and ordered (table above).
  • Friendly name added under llm.tools.<name> in en/translation.json, imperative tense.
  • Spec covers happy path and every guard branch, asserting the literal { error: ... } object — and that the success path does NOT leak an error property (expect(result).not.toHaveProperty("error")).

Reference map

FileWhen to open
references/spec-harness.mdWriting the *_tools.spec.ts — the getTool() iterator, Pattern A (mock persistence, no CLS), Pattern B (real becca + cls.init), and the error-object assertions.

Cross-links: writing-unit-tests (general Vitest patterns, the CoreApiTester, becca/froca fixtures, single-file run commands), translating-locales (why en-only and how Weblate picks up the rest), analyzing-coverage (chasing the spec to 100%).

© TriliumNext, AGPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in .claude/skills/adding-llm-mcp-tools of TriliumNext/Trilium.

  • SKILL.md
  • references/spec-harness.md

Open the folder on GitHubat commit cac2b4f

Compare with similar skills

Adding LLM MCP Tools next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Adding LLM MCP Tools compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Adding LLM MCP Tools this skillTriliumNext/Trilium38k—~2.5kAutomated safety check: PassAGPL-3.0
MCP Testingadeze/raindrop-mcp188—~1.6kAutomated safety check: PassMIT
Edt MCP YaxunitDitriXNew/EDT-MCP295—~2.5kAutomated safety check: PassAGPL-3.0
Edt MCP TestingDitriXNew/EDT-MCP295—~2.1kAutomated safety check: PassAGPL-3.0
Add UI Stringopenfootmanager/openfootmanager1.1k—~2.6kAutomated safety check: PassGPL-3.0
Playwright Testingchongdashu/vibejam-starter-pack149—~2.2kAutomated safety check: PassNone

Similar skills

  • MCP Testing

    adeze/raindrop-mcp

    MCP Testing Strategies with Vitest, Inspector, and Integration Tests

    188 GitHub stars~1.6k tokensUpdated 2 mo ago
    Testing & QAAuto-check passed
  • Edt MCP Yaxunit

    DitriXNew/EDT-MCP

    How to write and run YAXUnit unit tests for a 1C configuration through 1C:EDT + the EDT-MCP runyaxunittests / debugyaxunittests tools.

    295 GitHub stars~2.5k tokensUpdated today
    Testing & QAAuto-check passed
  • Edt MCP Testing

    DitriXNew/EDT-MCP

    How to manually e2e-test each EDT-MCP server tool against a live EDT workbench + TestConfiguration.

    295 GitHub stars~2.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Add UI String

    openfootmanager/openfootmanager

    Add or change any text a player can see, in every locale the game ships in.

    1.1k GitHub stars~2.6k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Playwright Testing

    chongdashu/vibejam-starter-pack

    Plan, implement, and debug frontend tests: unit/integration/E2E/visual/a11y.

    149 GitHub stars~2.2k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Frontend Playwright E2E

    ansible/ansible-ui

    Write, run, and debug Playwright E2E / integration / live tests.

    113 GitHub stars~2.5k tokensUpdated today
    Testing & QAAuto-check: notes

More from TriliumNext/Trilium

All 22 skills in this repo
  • Cutting A Release

    TriliumNext/Trilium

    A skill your agent uses when cutting, preparing, or debugging a Trilium release — bumping the monorepo version, tagging, or diagnosing a failed "Release" workflow run.

    38k GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Developing Electron Desktop

    TriliumNext/Trilium

    A skill your agent uses when working on the Trilium Electron desktop app (apps/desktop) — adding or changing an electronApi method / IPC channel, touching preload.ts, main.ts, services/window.ts or…

    38k GitHub stars~5.7k tokensUpdated today
    Auto-check passed
  • Evolving The Data Model

    TriliumNext/Trilium

    A skill your agent uses when adding a DB migration or a new column/field to a Becca entity in Trilium ("add a migration", "new column on notes/attributes", "ALTER TABLE", "add a field to…

    38k GitHub stars~2.1k tokensUpdated today
    Auto-check passed
  • Adding Internal API Route

    TriliumNext/Trilium

    A skill your agent uses when adding, moving, or wiring an internal REST endpoint in Trilium (a new /api/ route) — choosing between a core-shared handler (packages/trilium-core/src/routes/index.ts…

    38k GitHub stars~3.3k tokensUpdated today
    Auto-check passed
  • Ckeditor5 Plugin Development

    TriliumNext/Trilium

    Write, extend, and review CKEditor 5 plugins in the Trilium (TriliumNext Notes) monorepo — the rich-text-note editor under packages/ckeditor5, whose plugins live in src/plugins/.

    38k GitHub stars~4.8k tokensUpdated today
    Auto-check passed
  • Ckeditor5 Testing

    TriliumNext/Trilium

    Testing CKEditor 5 plugins in the Trilium monorepo. An agent skill from TriliumNext/Trilium.

    38k GitHub stars~3.3k tokensUpdated today
    Auto-check passed

Questions about Adding LLM MCP Tools

What does Adding LLM MCP Tools do?

A skill your agent uses when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ —…. Adding LLM MCP Tools is an agent skill from TriliumNext/Trilium. Use when adding, changing, or reviewing an LLM/MCP tool in Trilium (the defineTools definitions under packages/trilium-core/src/services/llm/tools/ — note/attribute/attachment/hierarchy/icon/skill tools) — anything exposed to both the in-app LLM chat and the external MCP server.

When should I use Adding LLM MCP Tools?

Adding LLM MCP Tools fits situations like: client-side note UI; ETAPI endpoints; generic Vitest questions (see writing-unit-tests).

How do I install Adding LLM MCP Tools in Claude Code?

Run `npx skills add TriliumNext/Trilium --skill adding-llm-mcp-tools -a claude-code`. Or copy the skill folder (.claude/skills/adding-llm-mcp-tools in TriliumNext/Trilium) into .claude/skills/adding-llm-mcp-tools in your project. Claude Code loads it when a task matches its description.

How do I install Adding LLM MCP Tools in Codex?

Run `npx skills add TriliumNext/Trilium --skill adding-llm-mcp-tools -a codex`. Or copy the skill folder (.claude/skills/adding-llm-mcp-tools in TriliumNext/Trilium) into .agents/skills/adding-llm-mcp-tools in your project. Codex loads it when a task matches its description.

Can I use Adding LLM MCP Tools in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add TriliumNext/Trilium --skill adding-llm-mcp-tools -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/adding-llm-mcp-tools, .gemini/skills/adding-llm-mcp-tools, .github/skills/adding-llm-mcp-tools and .opencode/skills/adding-llm-mcp-tools in your project.

What does Adding LLM MCP Tools need to run?

Going by SKILL.md and its folder, Adding LLM MCP Tools needs the command-line tools its instructions call (git and pnpm).

Does Adding LLM MCP Tools access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Adding LLM MCP Tools safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Adding LLM MCP Tools use?

Adding LLM MCP Tools is published under the AGPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Adding LLM MCP Tools use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.3k tokens, read only when the agent opens those files.

What are the alternatives to Adding LLM MCP Tools?

Skills that share tags, products or a category with Adding LLM MCP Tools: MCP Testing (adeze/raindrop-mcp, 188 stars), Edt MCP Yaxunit (DitriXNew/EDT-MCP, 295 stars), Edt MCP Testing (DitriXNew/EDT-MCP, 295 stars) and Add UI String (openfootmanager/openfootmanager, 1.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Adding LLM MCP Tools?

TriliumNext (a GitHub organization) maintains it in TriliumNext/Trilium, which has 38,248 GitHub stars. The repository holds 22 skills in this directory. The repository was last updated on October 8, 2026.

Source: TriliumNext/Trilium on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.