Skip to main content
Glama
vtt-standardnotes-mcp

vtt-standardnotes-mcp

by vtttech
README.md
# vtt-standardnotes-mcp

Private stdio MCP server giving Lumo (or any MCP client) end-to-end encrypted read/write access to a [Standard Notes](https://standardnotes.com) vault.

## Why

- **No credentials in your MCP client settings.** A one-time interactive `login` stores an encrypted session in the OS keychain (Windows Credential Manager, macOS Keychain, or Linux Secret Service via gnome-keyring). The MCP client config only ever holds your email - nothing secret.
- **E2EE intact.** Password and master key never leave this machine's RAM. Standard Notes' servers see ciphertext only, same as the official apps.
- **Local stdio only.** No network port is opened. Ever.
- **Single repo, complete package.** Clone, install, build, login, connect. Nothing else to fetch.

## Requirements

- Node.js >= 20
- Windows / macOS / Linux with a working OS keychain (Linux needs gnome-keyring or another Secret Service provider, plus libsecret)
- A Standard Notes account on protocol 004 (any account created or upgraded since 2020)

## Setup

```bash
git clone https://github.com/vtttech/vtttech-standardnotes-mcp.git
cd vtt-standardnotes-mcp
npm install
npm run build
```

### One-time login (per machine)

```bash
npm run login
```

Prompts for email, password, and 2FA code. Derives your master key in RAM via Argon2id, signs in, and stores the session in the OS keychain. The password is discarded immediately after key derivation - never written to disk, never stored anywhere.

After login, the server resumes from the keychain session automatically on every start. No password needed again until the session is revoked or you run `logout`.

### Linux specifics

The code is identical on every platform. The keychain layer (`@napi-rs/keyring`) handles the backend swap automatically: on Windows it uses the Credential Manager, on Linux it talks to the **Secret Service** (D-Bus API), normally provided by `gnome-keyring`. Your session lands there instead of the Windows Credential Vault - same schema, same login flow.

**Packages needed (Debian/Ubuntu/Mint):**

```bash
sudo apt install gnome-keyring libsecret-1-0
```

- `gnome-keyring` - runs the Secret Service daemon that stores the session
- `libsecret-1-0` - the D-Bus library the prebuilt keyring binary talks to
- `build-essential` + `python3` - only needed if you develop or rebuild from source; the release binary ships prebuilt, no compilation on `npm install`

Other distros: install `gnome-keyring` and `libsecret` from your package manager (Fedora: `gnome-keyring libsecret`; Arch: `libsecret` and a Secret Service implementation such as `gnome-keyring` or `keepassxc`).

**Verify the keychain works before logging in (optional but recommended):**

```bash
secret-tool store --service=vtt-sn-mcp-test account probe  # type a password, then
secret-tool lookup --service=vtt-sn-mcp-test account probe  # should echo it back
secret-tool clear --service=vtt-sn-mcp-test account probe   # cleanup
```

If `secret-tool` hangs or errors, the Secret Service is not running (common on headless/Wayland-started-without-keyring setups). On Mint/Cinnamon, GNOME session keyring is started by `libpam-gnome-keyring` at login; if your session was restored by a display-manager restart the daemon may not be active - see `docs/troubleshooting.md`.

**Headless / SSH notes:**

- The keyring must be unlocked to store/retrieve the session. Logging into your desktop normally unlocks the `login` keyring automatically; over SSH there is no PAM keyring unlock, so `npm run login` may prompt for a keyring password or fail to reach the D-Bus session bus. Run `npm run login` from a normal desktop session.
- If you truly cannot run a desktop session, export `DBUS_SESSION_BUS_ADDRESS` pointing at the user bus (`unix:path=/run/user/<uid>/bus`) and unlock the keyring with `gnome-keyring-daemon --unlock`, entering the keyring password at the prompt.

**MCP client paths on Linux:** the Windows example above uses `C:\path\...`; on Linux it is simply `/home/<user>/path/to/vtt-standardnotes-mcp/dist/index.js`.

```json
{
  "mcpServers": {
    "standard-notes": {
      "type": "stdio",
      "command": "node",
      "args": ["/home/<user>/vtt-standardnotes-mcp/dist/index.js"],
      "env": { "SN_EMAIL": "you@example.com" }
    }
  }
}
```

**Keychain library.** As of v0.7.0 this project uses `@napi-rs/keyring` (Rust bindings to keyring-rs, actively maintained) instead of the abandoned `keytar` package. Benefits: prebuilt native binaries per platform, so no node-gyp and no ABI mismatch on Node upgrades. Existing sessions written by old keytar builds use a different Secret Service attribute layout (`account` vs `username`); run the one-time migration below, or simply `npm run login` again.

**One-time migration of an existing keytar session (Linux):**

```bash
pip install secretstorage
python3 - << 'EOF'
import secretstorage
conn = secretstorage.dbus_init()
coll = secretstorage.get_default_collection(conn)
for item in coll.get_all_items():
    attrs = item.get_attributes()
    if attrs.get('service') == 'mcp-standardnotes' and 'account' in attrs:
        account = attrs['account']
        secret = item.get_secret()
        item.delete()
        coll.create_item(f'keyring:{account}@mcp-standardnotes',
            {'service': 'mcp-standardnotes', 'username': account,
             'xdg:schema': 'org.freedesktop.Secret.Generic'}, secret)
        print(f'MIGRATED: {account}')
EOF
```


### Wire it into Lumo

In Lumo's MCP server settings, add a server:

- **ID:** `standard-notes`
- **Display name:** `Standard Notes`
- **Transport:** Local (command)
- **Command:** `node`
- **Args:** `"C:\path\to\vtt-standardnotes-mcp\dist\index.js"` (wherever the repo lives on this machine)
- **Environment:** `SN_EMAIL=you@example.com`
- **Secret environment:** leave empty

### Other MCP clients

```json
{
  "mcpServers": {
    "standard-notes": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/vtt-standardnotes-mcp/dist/index.js"],
      "env": { "SN_EMAIL": "you@example.com" }
    }
  }
}
```

## Tools

| Tool | What it does |
|---|---|
| `notes_list` / `notes_search` / `notes_get` | Browse, search, read notes (filter by tag with `tag: "<uuid-or-title>"`) |
| `notes_create` / `notes_update` / `notes_delete` | Write notes (markdown, super, code, rich-text, task, spreadsheet, plain-text) |
| `notes_create_many` | Batch-create up to 50 notes in one sync push |
| `notes_stats` | Vault stats: counts, sizes, oldest/newest/largest note |
| `tags_list` / `tags_get` / `tags_create` / `tags_update` / `tags_delete` | Full tag CRUD |
| `tags_attach` / `tags_detach` | Link/unlink tags to notes |
| `sync` | Force a sync with the server |

## Configuration

| Variable | Default | Description |
|---|---|---|
| `SN_EMAIL` | required | Account email. Must match the email used at `npm run login` exactly. |
| `SN_SERVER_URL` | `https://api.standardnotes.com` | Sync server. Change for self-hosted. |
| `KEYCHAIN_SERVICE` | `mcp-standardnotes` | Keychain service name (useful for multiple accounts). |
| `SN_CERT_FINGERPRINT` | unset | SHA-256 TLS cert pin for self-hosted servers. See docs/self-hosted.md. |

## Auth lifecycle

- **`npm run login`** - one-time, interactive: email + password + 2FA. Session lands in the OS keychain.
- **Every server start** - reads the keychain session, no login round-trip, decrypts locally with the stored master key.
- **Access token expiry** - refreshed automatically from the stored refresh token. Invisible to you.
- **`npm run logout`** - wipes the keychain session. Use this to revoke MCP access without touching your SN password.

## Security

- Password exists in RAM only during login key derivation. Never logged, never stored.
- Session tokens and master key hex live in the OS keychain only.
- stdio transport. No HTTP listener.
- Logs go to stderr through a redactor that masks passwords, keys, JWTs, and token-like strings.
- All tool inputs validated with zod.
- Crypto primitives from `libsodium-wrappers-sumo` (Argon2id + XChaCha20-Poly1305).

## Troubleshooting

See [docs/troubleshooting.md](./docs/troubleshooting.md).

## 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.