skip to content

TriliumNext

An agent for notes, for requests such as “note that the boiler was serviced today”.

MCP server github.com/perfectra1n/triliumnext-mcp
Transport Streamable HTTP
Authentication bearer

In Compose, beside the server of Ambrogio:

services:
trilium-mcp:
image: ghcr.io/perfectra1n/triliumnext-mcp:0.4.0
environment:
TRILIUM_URL: http://<trilium-host>:8080/etapi
TRILIUM_TOKEN: ${TRILIUM_ETAPI_TOKEN:?}
TRILIUM_TRANSPORT: http
TRILIUM_HTTP_HOST: 0.0.0.0
TRILIUM_HTTP_PORT: "3000"
TRILIUM_GATEWAY_AUTH: bearer
TRILIUM_GATEWAY_TOKENS: ${TRILIUMNEXT_MCP_TOKEN:?}

It serves Streamable HTTP on port 3000 at /mcp, so the server of Ambrogio reaches it at http://trilium-mcp:3000/mcp, the name of its Compose service on a network the two share; from another host, use the name or address of the host that runs it, with the same port and path. TRILIUM_GATEWAY_AUTH: bearer must be set explicitly for the server to check the token.

TRILIUM_TOKEN is how the MCP server signs in to TriliumNext: an ETAPI token, created in TriliumNext under Options, ETAPI.

  1. Run the MCP server, as Run the MCP server shows.

  2. Choose the token that the MCP server accepts, a random value such as the output of openssl rand -hex 32: the same value goes to the MCP server, as TRILIUM_GATEWAY_TOKENS above, and to Ambrogio. Write it in .env as TRILIUMNEXT_MCP_TOKEN, and pass the variable to the server of Ambrogio in compose.yaml:

    services:
    server:
    environment:
    TRILIUMNEXT_MCP_TOKEN: ${TRILIUMNEXT_MCP_TOKEN:?}
  3. Add the agent file agents/triliumnext.json, with the address of the Streamable HTTP endpoint of the MCP server in mcp.url:

    {
    "description": "Answers the household's requests about notes, with the tools of TriliumNext.",
    "instructions": "You handle the household's requests about notes with the tools of TriliumNext. Requests may come from speech recognition and contain misheard words; interpret them in context. Answer briefly.",
    "llm": {
    "provider": "mistral",
    "model": "mistral-medium-latest",
    "apiKeyEnv": "MISTRAL_API_KEY"
    },
    "maxToolCalls": 4,
    "mcp": {
    "url": "http://trilium-mcp:3000/mcp",
    "auth": {
    "type": "bearer",
    "tokenEnv": "TRILIUMNEXT_MCP_TOKEN"
    }
    }
    }
  4. Restart with docker compose up -d.

Authentication: a bearer token, which the agent file names through the variable TRILIUMNEXT_MCP_TOKEN. The description, the instructions, the language model and maxToolCalls are an example: adapt them to the household. See Agents for every field of the file.