Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Agents: MCP and agent devices

AI agents such as Claude Code, or any client of the Model Context Protocol, can read people’s notes and, if allowed, edit them. There are three places that serve them:

ServesForWhere it runs
The server’s /mcpStandard workspacesYour server, on by default
An agent deviceEnd-to-end encrypted workspaces (and standard ones)Wherever the agent runs: a container beside it, a home server, a laptop
The desktop app’s local MCPWhatever the app has openThe person’s computer, while the app is open

The tools are the same everywhere: list_workspaces, list_pages, read_page, read_journal, search, create_page, append_to_page, update_page, publish_page, query_database, add_row, update_row and create_database. None of them deletes. Every change an agent makes is recorded, and people undo it from Settings → Agents. How people connect agents is in Agents and MCP.

The server’s /mcp

Agents connect to https://notes.example.com/mcp (MCP over Streamable HTTP). With Claude Code:

claude mcp add --transport http drusite https://notes.example.com/mcp

The agent signs in through the browser as an app does, using a Client ID Metadata Document, so there’s no registration step. A consent page then asks the person:

  • which workspace it can see;
  • read only, or read and edit (never more than their own role);
  • whether it may edit journal entries (off unless allowed);
  • whether it may publish pages to the web (off unless allowed).

Its tokens are good at /mcp only (RFC 8707). An agent that can’t open a browser, such as one on a server, uses a token made on the account page (/account → Agents → Make a token), sent as Authorization: Bearer <token>. Disconnecting an agent ends its access at once.

[agents]
enabled = true                      # false turns /mcp off
max_token_days = 365                # the longest an account-page token can last
# allow_insecure_client_ids = false # development only

When the server fetches a client’s metadata document it refuses addresses on private networks, unless allow_insecure_client_ids is on (only for testing a client on your own machine). Your proxy must pass /mcp, /oauth/… and /.well-known/oauth-protected-resource through to the server.

Agent devices

The server can’t read an end-to-end encrypted workspace, so it can’t serve agents for one. An agent device is a small, headless Drusite that belongs to one person: it’s approved like a new phone, holds keys for only the workspaces that person gives it, keeps an encrypted copy of them, and serves the same MCP tools.

What an agent device can reach:

  • Only the workspaces ticked when it was added. It gets keys for those and nothing else, not even the person’s other workspaces.
  • Private pages and pages shared with the person, in those workspaces, only if that box was ticked.
  • Read only, or edit up to the person’s own role. The server checks again on every push.
  • It never gets the person’s root key, so it can’t approve other devices, and it can’t publish.

Agents sign in to it through your server, with the same consent page, the same list in Settings → Agents and the same revocation. The server’s /mcp points agents at the agent device for the workspaces it serves.

Running one

The person starts in the app: Settings → Agents → Add an agent device, picks what it may read, and gets a one-time enrollment code (good for 15 minutes). Then, wherever it should run:

As a binary (from the release’s drusite-agent-<version>-<target> archives):

drusite agent run \
  --address https://agents.example.com \
  --server https://notes.example.com \
  --code ABCDE-FGHJK

As a container, with its store key made once and kept:

openssl rand -hex 32 > agent-store-key
docker run -d --name drusite-agent --restart unless-stopped -p 8790:8790 \
  -v drusite-agent:/data \
  -e DRUSITE_AGENT_STORE_KEY="$(cat agent-store-key)" \
  -e DRUSITE_AGENT_ADDRESS=https://agents.example.com \
  -e DRUSITE_AGENT_SERVER=https://notes.example.com \
  -e DRUSITE_AGENT_CODE=ABCDE-FGHJK \
  ghcr.io/pranavajk1/drusite-agent:1

The image runs drusite agent run, keeps its data in /data and listens on 0.0.0.0:8790.

On Kubernetes: the chart’s agentDevice values.

On its first start it enrolls, then waits: the app shows “A new device wants your keys” with a six-digit code, and the agent device logs the same code. When they match, Approve. After that the code isn’t needed; the agent device signs in with its own key.

  • --address is where agents reach it, as they’ll name it. Its MCP endpoint is <address>/mcp, so put it behind HTTPS like the server.
  • Its store key (64 hex digits) encrypts its copy. Give it in DRUSITE_AGENT_STORE_KEY, or a file named by --store-key-file; with neither, enroll makes one in its data folder. Keep it with the data folder: without it, the copy can’t be opened and the agent device must be added again.
  • drusite agent status says what it is: its server, its name, how many workspaces it reads, and whether it may edit.

Every flag and variable is in the drusite agent reference.

Who controls it

Whoever controls an agent device’s host can read what it holds: that’s the point of it. Members of a workspace see each agent device that can read it, and whose it is. Owners can turn agent devices off for their workspace (Settings → AI → Allow agent devices), which takes their keys away. You can turn them off for the whole server:

[e2ee]
agent_devices = false

Removing an agent device signs it out and replaces every key it held.