vtt-standardnotes-mcp
by vtttech
README.md
# standardnotes-mcp
A private [MCP](https://modelcontextprotocol.io) server that gives AI assistants (Lumo, Claude, Kimi, or any MCP client) end-to-end-encrypted access to your [Standard Notes](https://standardnotes.com) vault — with per-client scopes and per-note governance enforced in the server, not by asking the AI nicely.
## Why
- **No credentials in your AI client's settings.** A one-time login stores the session in the OS keychain (Windows Credential Manager, macOS Keychain, Linux Secret Service). Client configs hold only your email and a name — nothing secret.
- **E2EE intact.** Your password and master key never leave this machine's RAM. Standard Notes' servers see ciphertext only, same as the official apps.
- **Per-AI control.** Confine each AI client to specific folders, mark notes read-only or invisible per client, and know that every rule is enforced server-side — a misbehaving or prompt-injected model cannot reach what the server refuses to serve.
- **Local stdio only.** No network port is opened. Ever.
## Requirements
- Node.js >= 20
- Windows / macOS / Linux with a working OS keychain (Linux: see [Platform notes](#platform-notes-linux))
- A Standard Notes account on protocol 004 (any account created or upgraded since 2020)
## Quick start
```bash
git clone https://github.com/vtttech/standardnotes-mcp.git
cd standardnotes-mcp
npm install
npm run build
npm run setup
```
`npm run setup` is the whole onboarding: if no session exists it runs the login flow first (email, password, 2FA — the password is used once for key derivation and discarded), then walks you through connecting your AI clients. With a session already stored it goes straight to client wiring, so re-run it any time you want to add or reconfigure a client.
Standalone commands, if you prefer:
| Command | What it does |
|---|---|
| `npm run login` | Authenticate and store the session in the OS keychain (re-login, or add another account) |
| `npm run setup` | Connect AI clients (runs login first if needed) |
| `npm run logout` | Wipe the keychain session — revokes MCP access without touching your SN password |
## Connecting AI clients
`npm run setup` offers Claude Desktop, Claude Code, ChatGPT, Kimi Code, Lumo, Cursor, or any custom client. For file-based clients (Claude Desktop, Cursor) it writes the config directly, with a timestamped backup; for the rest it prints a ready-to-paste snippet.
Every client entry carries two env vars that matter:
```json
{
"mcpServers": {
"standard-notes": {
"command": "node",
"args": ["/absolute/path/to/standardnotes-mcp/dist/index.js"],
"env": {
"SN_EMAIL": "you@example.com",
"SN_CLIENT_NAME": "claude",
"SN_READ_TAGS": "some-folder"
}
}
}
}
```
- `SN_EMAIL` — which account (must match login exactly).
- `SN_CLIENT_NAME` — the client's **governance identity**. Per-client frontmatter rules (`ai-claude: ...`) match against it. Set it explicitly: it then comes from a config file *you* wrote rather than being self-reported by the client. The name never affects whether the client connects — only which rules apply to it.
- `SN_READ_TAGS` — optional **folder scope** (see below). Omit for full-vault access.
**Lumo specifics:** in Lumo's MCP settings add a server with transport "Local (command)", command `node`, args `[".../dist/index.js"]`, and environment `SN_EMAIL` + `SN_CLIENT_NAME=lumo`. Leave "secret environment" empty.
Restart the client fully after changing its config.
## Limiting an AI to folders (scopes)
Standard Notes folders are tags, so scopes are tag-based. Set in the client's config, enforced in the server process:
| Variable | Effect |
|---|---|
| `SN_READ_TAGS=wsd` | **Allowlist.** The client can only see notes under the `wsd` tag *and its child tags*. Everything else — list, search, stats, smart views, tag names — behaves as if it doesn't exist. Creates must file under an in-scope tag; retags must keep one; tag moves/renames/deletes only work inside the subtree; the scope root itself is immutable to the client. |
| `SN_DENY_TAGS=journal,private` | **Blocklist.** Everything is visible *except* these tag subtrees. Deny wins over allow. |
| `SN_READ_ONLY=true` | Write tools are not registered at all — the AI only sees read tools. |
Notes on behavior:
- "Out of scope" is indistinguishable from "doesn't exist" — no existence probing, no title leaks, and no way to tag/attach/move content across the boundary (every path is checked).
- Example: with `SN_READ_TAGS=WSD`, asking that client for `notes_stats` returns counts for the WSD subtree only, and your journal is unreachable no matter how the model is prompted.
- Combine freely: `SN_READ_TAGS` for the working set, `SN_DENY_TAGS` for carve-outs, `SN_READ_ONLY` for read-only clients.
## Per-note governance (frontmatter)
Any markdown/plain-text note can declare how AIs may treat it, via a YAML block at the top of the note body:
```yaml
---
ai: read-only # every AI: readable, never editable
ai-claude: no-access # Claude specifically: invisible
ai-kimi: ok # Kimi specifically: full access (per-client beats global)
---
```
| Key | Meaning |
|---|---|
| `ai: ok` (or absent) | Full access |
| `ai: read-only` | Readable; every AI write path refuses (`governance_read_only`) |
| `ai: no-access` | Hidden everywhere; reads and writes fail as "not found" |
| `ai-<name>: <policy>` | Per-client override, matched case-insensitively against `SN_CLIENT_NAME` |
Rules of the road:
- **Write order matters**: to protect a note with `ai: no-access` + `ai-<name>: ok`, write the allow key FIRST, then the deny — reversed, you lock out the client doing the writing.
- **Fail-safe pattern for sensitive notes**: `ai: no-access` + `ai-<name>: ok`. A name mismatch then keeps the note hidden instead of exposing it (mismatches otherwise fail open — the per-client rule just doesn't apply).
- **`super` (rich-text) notes can't carry frontmatter** — govern those with config scopes.
- Manage keys with the `notes_frontmatter` tool or by hand in the app. Enforcement is in the server, so governance keys can't be removed by an AI even with write access elsewhere (`ai: read-only` is evaluated before any edit lands).
- Set `SN_GOVERNANCE=off` to disable enforcement entirely (not recommended).
## The security model — what each layer stops
Be clear-eyed about what a rule can bind:
1. **The AI model** — fully bound. Refused content never enters its context; no prompt, injection, or persuasion changes what the server serves. This covers the realistic threats: a curious model, an accident, a poisoned note trying to redirect the agent.
2. **The client app** — mostly bound. Scopes and identity come from config *you* wrote. A client app that deliberately tampered with its own config could widen its scope — spot-check with the `sn://status` resource, which reports the active identity and policy.
3. **Code running as your OS user** — not bound, and can't be. Any process running as you can read your keychain or launch the server with different env. Keep AI sessions that can touch the vault away from AI sessions that can touch your filesystem/shell, don't grant agents access to `AppData`/home dirs, and use a separate OS user or a separate SN account if you need a boundary that survives malicious software.
One more honest limit, worth internalizing: enforcement bounds what a tool call can **do** — it can't stop an agent from following bad instructions hidden in text it **reads** (prompt injection). Note content is data, not commands; keep untrusted reading and sensitive sending out of the same session.
## Tools
30+ tools, all validating input with zod. Mutating note tools return size deltas (`previousSizeInBytes`/`currentSizeInBytes`) so an accidental clobber is visible without a re-read.
**Reading & finding**
| Tool | What it does |
|---|---|
| `notes_list` | Browse notes, newest-updated first; filter by tag/folder (`includeDescendants` for subtrees) |
| `notes_search` | Full-text search — `text` mode (all words match) or `regex`; filters: tag, noteType, date range (timezone-aware), trashed; snippets + cursor pagination |
| `notes_get` | Read one note. `format`: `content` (default), `full`, `outline` (heading map), `section` (one heading's body) |
| `notes_query` | Structured queries with SN's Smart View predicate JSON (and/or/not trees over title, text, trashed, archived, pinned, noteType, tagsCount…) |
| `smartviews_list` / `smartviews_notes` | List your SN Smart Views (saved searches) and run one — evaluated locally |
| `notes_stats` | Vault stats: counts, sizes, note types, decrypt failures, cache age |
| `notes_tasks` | Find markdown checkbox tasks across the vault (open by default; filter by tag/note) |
**Writing & editing**
| Tool | What it does |
|---|---|
| `notes_create` / `notes_create_many` | Create one note, or up to 50 in one sync push |
| `notes_update` / `notes_update_many` | Replace body/title/type/tags, archive/pin, trash/restore — single or batch with per-note failure reporting |
| `notes_append` | Insert text without resending the body — whole note or one heading section (`"Parent::Child"`), append/prepend |
| `notes_replace_in` | Find-and-replace inside one note: literal or regex (ReDoS-guarded), per-rule counts |
| `notes_delete` / `notes_delete_many` | Trash (recoverable) or purge (`permanent: true`); single or batch |
| `notes_frontmatter` | Get/set/delete YAML frontmatter keys (line surgery — the rest of the block is preserved byte-for-byte) |
| `notes_task_toggle` | Check/uncheck a task found by `notes_tasks` |
| `daily_append` | Append to today's journal note (creates `Journal YYYY-MM-DD`; appears in the SN app's Daily view) |
**Organization & history**
| Tool | What it does |
|---|---|
| `tags_list` / `tags_get` | Folder structure with note counts (scoped clients see only their subtree) |
| `tags_create` / `tags_update` / `tags_delete` | Create/rename/move/delete folders (scoped clients: inside their subtree only) |
| `tags_attach` / `tags_detach` | File/unfile notes (guarded against orphaning notes out of scope) |
| `daily_list` | Notes created on a date (matches the SN Daily view) |
| `notes_history` / `notes_revision_get` / `notes_revision_restore` | List, read, or restore server-kept revisions (subscription-gated upstream) |
| `vault_export` | Export decrypted notes as markdown + `index.json` — only registered when `SN_ALLOW_EXPORT=true` |
| `sync` | Force a full re-sync (writes always sync first regardless) |
**Resources & prompts:** `sn://notes/{uuid}`, `sn://tags`, `sn://status` (sync state + active identity/policy); prompts `summarize-note`, `weekly-review`, `inbox-triage`.
## Configuration
| Variable | Default | Description |
|---|---|---|
| `SN_EMAIL` | required | Account email; must match login exactly |
| `SN_CLIENT_NAME` | handshake name | Governance identity for `ai-<name>` rules — set per client |
| `SN_READ_TAGS` | unset | Allowlist: only these tag subtrees are visible (see [scopes](#limiting-an-ai-to-folders-scopes)) |
| `SN_DENY_TAGS` | unset | Blocklist: hide these tag subtrees; deny wins |
| `SN_READ_ONLY` | `false` | `true` = write tools not registered |
| `SN_GOVERNANCE` | `on` | Frontmatter `ai:` enforcement; `off` disables |
| `SN_DELETE_ELICITATION` | `false` | `true` = deletions require interactive confirmation |
| `SN_ALLOW_EXPORT` | `false` | `true` registers `vault_export` (writes decrypted plaintext to disk) |
| `SN_EXPORT_DIR` | unset | Confine exports to this directory tree |
| `SN_SERVER_URL` | `https://api.standardnotes.com` | Sync server (self-hosted: see [docs/self-hosted.md](./docs/self-hosted.md)) |
| `SN_CERT_FINGERPRINT` | unset | SHA-256 TLS cert pin for self-hosted servers |
| `SN_CACHE_TTL_MS` | `30000` | Read-cache freshness window (`0` = sync before every read) |
| `SN_TIMEZONE` | `America/Los_Angeles` | IANA timezone for date-only filters and journal tools |
| `KEYCHAIN_SERVICE` | `mcp-standardnotes` | Keychain service name (multiple accounts) |
## Auth lifecycle
- **Login** (via `npm run setup` or `npm run login`): email + password + 2FA, once per machine. Master key derived in RAM (Argon2id); session stored in the OS keychain.
- **Every server start**: reads the keychain session — no password, no login round-trip; decrypts locally.
- **Token expiry**: refreshed automatically from the stored refresh token.
- **`npm run logout`**: wipes the keychain session.
## Platform notes (Linux)
The code is identical everywhere; `@napi-rs/keyring` swaps the backend. On Linux the session lands in the **Secret Service** (usually gnome-keyring):
```bash
sudo apt install gnome-keyring libsecret-1-0 # Debian/Ubuntu/Mint
```
The keyring must be unlocked — a normal desktop login does this; headless/SSH sessions need `DBUS_SESSION_BUS_ADDRESS` and `gnome-keyring-daemon --unlock` (see [docs/troubleshooting.md](./docs/troubleshooting.md)). Migrated from an old `keytar`-based install? Either `npm run login` again or run the one-time attribute migration in [docs/troubleshooting.md](./docs/troubleshooting.md).
## Development
```bash
npm run typecheck && npm run lint && npm test && npm run build # full gate
npm test # vitest (208 tests)
npm run dev # tsx watch
```
## Troubleshooting & security
- [docs/troubleshooting.md](./docs/troubleshooting.md) — common errors and fixes
- [SECURITY.md](./SECURITY.md) — full security posture and how to report vulnerabilities
- [docs/protocol-004.md](./docs/protocol-004.md) — encryption protocol notes
- [docs/self-hosted.md](./docs/self-hosted.md) — self-hosted server setup
## Credits & license
MIT. Based on [lozit/mcp-standardnotes](https://github.com/lozit/mcp-standardnotes) by Guillaume Ferrari. Cryptographic primitives by [libsodium](https://doc.libsodium.org). Developed in collaboration with [Lumo](https://lumo.proton.me), Proton's private AI assistant.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues