manage-trilium-instances
Skill0 starsChanged 2 months agoMITView on GitHub
Configure connections to one or more trilium-mcp deployments — add a new instance (URL + ETAPI token, optionally labeled), list which are configured/connected, or remove one. Every instance is registered as a user-scoped MCP server via `claude mcp add` (no settings.json editing, no bundled .mcp.json). Use when the trilium MCP server is unconfigured, disconnected, or missing credentials (including when a SessionStart hook flags this), when the user asks to set up, configure, or connect the Trilium plugin, or when they want to add, remove, or list additional Trilium instances.
In this repository11 other files it gives its agents.
- apply-template-to-noteSkill
- create-note-from-templateSkill
- create-noteSkill
- delete-noteSkill
- export-note-subtreeSkill
- find-template-instancesSkill
- journal-noteSkill
- manage-note-attributesSkill
- move-noteSkill
- rename-noteSkill
- search-notesSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
Run claude mcp get trilium — exit code 0 means it's already registered (the output includes its scope and live connection status.
- Very specific: line 22
If either signal is true, stop here — report that it's already configured (naming the scope from claude mcp get's output, e.g.
- Distinctive: line 31
Never print the token back in a confirmation message or log it.
- Very specific: line 43
Run claude mcp list — it health-checks every configured server fresh, including ones just added this session, and works regardless of …
- Very specific: line 49
Ask which instance (by label, or "default" for trilium) if not already clear.
- Very specific: line 50
Run claude mcp remove trilium for the default, or claude mcp remove <name> with the instance's exact server name (e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Manage Trilium Instances
Every Trilium instance — including the first/default one — is its own MCP server registered with the claude mcp add CLI command, scoped user so it's available to every project under the current Claude Code installation. The default instance is named trilium; each additional one is trilium-<label> (e.g. trilium-work), the naming the trilium-mcp docs use too. Instances registered earlier as trilium_<label> still count. Claude Code exposes each server's tools under its own prefix (mcp__trilium__*, mcp__trilium-work__*, …); skills resolve which prefix to use per task — see Working with multiple instances.
This skill is the only way instances get configured. Go through claude mcp add/list/get/remove only. Never write an mcpServers block into settings.json (it rejects the key) and never create a .mcp.json.
Determine the operation
Figure out from the request whether the user wants to add a new instance, list what's configured, or remove one. Default to add when the trigger is a missing-credentials nudge and the user hasn't said otherwise.
Add an instance
Check whether the default instance is already configured before asking anything, if this is meant to be the first/default instance. Two independent signals both indicate it's already in place:
- The
mcp__trilium__*tools are already listed as available in this session (see the system-reminder of connected MCP tools) — this proves the current registration is valid and connected. - Run
claude mcp get trilium— exit code 0 means it's already registered (the output includes its scope and live connection status; never print the token, which thegetoutput doesn't show anyway).
If either signal is true, stop here — report that it's already configured (naming the scope from
claude mcp get's output, e.g. "user config") and finish. Only continue if the user explicitly wants an additional instance, or neither signal is true.- The
If this is an additional instance (not the first), ask for a label — a short name like
workorhome. Sanitize it: lowercase, replace every run of characters outside[a-z0-9]with-, strip leading/trailing-. If the result is empty, ask for a different one. Then runclaude mcp get trilium-<label>— exit 0 means that name is already taken (its error output for a miss conveniently lists every configured server too, useful for suggesting a free label) — ask for a different label rather than silently overwriting an existing instance.Skip this step entirely for the first/default instance — it always stays unlabeled (server name
trilium).- Ask for the remaining values, one at a time (plain question or
AskUserQuestionif available):- The instance's MCP URL. For the default instance,
http://localhost:8081/mcpis a common value for a local devtrilium-mcpstack — offer it as a suggestion, but there's no automatic fallback anymore, so still ask. For a labeled instance, there's no natural default — just ask. - Its ETAPI token, created from that Trilium instance's Options → ETAPI screen. Required, no default.
- Never print the token back in a confirmation message or log it.
- The instance's MCP URL. For the default instance,
Register the instance by running:
claude mcp add --transport http <name> "<url>" -H "Authorization: <token>" -s userwhere
<name>istriliumfor the default instance ortrilium-<label>for an additional one.-s usermakes it available to every project under this installation. The token appears in this command's arguments (visible in the tool call, and briefly in process listings while it runs) — there's no CLI option to supply it another way; don't additionally print or log it anywhere else.- Tell the user to restart Claude Code (or start a new session) — a newly
claude mcp add-ed server only connects into the current session's tool list after a restart.
List instances
- Run
claude mcp list— it health-checks every configured server fresh, including ones just added this session, and works regardless of what's already loaded into the current session's tool list. - From its output, keep only lines whose server name matches
trilium([-_].+)?(a literaltrilium, plus anytrilium-<label>or oldertrilium_<label>). Each line ends with a connection status (e.g. "✔ Connected" or "✘ Failed to connect — ..."). - Report the list: label (or "default" for
trilium), and connected/not-connected per that status. Never print token values.
Remove an instance
- Ask which instance (by label, or "default" for
trilium) if not already clear. - Run
claude mcp remove triliumfor the default, orclaude mcp remove <name>with the instance's exact server name (e.g.trilium-work) for an additional one (no-sneeded — it removes from whichever scope it's registered in). - Tell the user to restart Claude Code for the removal to take effect.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

