Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Releases up to 0.3.5 are described on the [GitHub releases page](https://github.

## [Unreleased]

### Added
- **AI apps can change notes over MCP, if you allow it.** A new **Allow changes** switch in **Settings → MCP server**, off by default and confirmed when turned on, gives AI apps five more tools: `create_note`, `edit_note` (replaces one exact passage), `append_to_note`, `move_note` and `delete_note` (to the trash). Changes are saved like typing: the open editor and the sidebar update at once and paired devices receive them. Apps that support tool list updates see the tools appear and disappear without reconnecting. Changes are limited to 256 KiB per call and 60 a minute. See [docs/MCP.md](docs/MCP.md).

## [0.5.3] - 2026-11-13

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ LowNotes is an **open-source, local-first Markdown note-taking app** for Windows
- **Connect your computers.** Pair devices for encrypted P2P sync and real-time collaborative editing.
- **Build a knowledge base.** Use folders, search, wikilinks, a connection map and Mermaid diagrams.
- **Choose your assistant.** Use local models through Ollama or LM Studio, or configure a remote provider. Remote requests send the prompt and selected context to that provider. The Research skill sends search terms (never notes) to the web search services you enable; only DuckDuckGo is on by default.
- **Bring your own AI app.** Claude Desktop, Claude Code, Cursor and other MCP clients can search and read the open vault while LowNotes sits in the tray. It is read-only and off by default.
- **Bring your own AI app.** Claude Desktop, Claude Code, Cursor and other MCP clients can search and read the open vault while LowNotes sits in the tray, and change notes if you allow it. It is off and read-only by default.
- **Recover and share your work.** Review local history and trash, then export notes to Word or PDF.

| Day to day | When you need more |
Expand Down Expand Up @@ -121,7 +121,7 @@ Under **Settings → Web search**, Firecrawl, Keenable, Exa, DuckDuckGo and a pu

### AI apps over MCP

**Settings → MCP server** lets AI apps on this computer that speak the Model Context Protocol, such as Claude Desktop, Claude Code and Cursor, list, search and read the notes of the open vault and follow its links. They cannot change notes. Apps launch the `lownotes-mcp` program installed next to LowNotes, which authenticates with a token kept in the system credential store. Only vaults you share are served, and what an app reads goes to that app and its AI provider. See [docs/MCP.md](docs/MCP.md) for setup, the available tools and the safety notes.
**Settings → MCP server** lets AI apps on this computer that speak the Model Context Protocol, such as Claude Desktop, Claude Code and Cursor, list, search and read the notes of the open vault and follow its links. With **Allow changes** on, they can also create, edit, move and delete notes; deleted notes go to the trash. Apps launch the `lownotes-mcp` program installed next to LowNotes, which authenticates with a token kept in the system credential store. Only vaults you share are served, and what an app reads goes to that app and its AI provider. See [docs/MCP.md](docs/MCP.md) for setup, the available tools and the safety notes.

## How it works

Expand Down
5 changes: 3 additions & 2 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The interface never reads the vault directly. Settings arrive through `AppSettin
| "Open with LowNotes" entries and launch arguments | `context_menu.rs` |
| Atomic storage and recovery notices | `storage.rs` |
| Vault listing and paths | `vault.rs` |
| Vault reads and assistant changes shared by commands and the MCP server | `vault_service.rs` |
| Vault reads and changes shared by commands and the MCP server | `vault_service.rs` |
| Stable note identities, deletes, moves | `catalog.rs`, `catalog_sync.rs`, `structural.rs`, `creation.rs` |
| Collaborative state and durable saves | `crdt.rs`, `note_transaction.rs` |
| History, trash, retention | `note_history.rs`, `retention.rs` |
Expand All @@ -70,7 +70,8 @@ The interface never reads the vault directly. Settings arrive through `AppSettin
- Tauri runs synchronous commands on the main thread. IO-heavy commands are `async` and run their body on the blocking pool through `on_worker` in `commands.rs`.
- The network service runs on its own thread with a two-worker Tokio runtime (`NetworkService::start`). Disk and CRDT phases inside network tasks go through `block_in_place`.
- `structural::exclusive` serializes structural work per vault with a reentrant lock and runs pending recovery on the outermost entry.
- The MCP server (`McpService`) runs on Tauri's async runtime: one task accepts connections on the per-user pipe or socket, and one task per client runs its session. Tool calls run on the blocking pool, like `on_worker`. A restart waits for the previous server to release the endpoint.
- The MCP server (`McpService`) runs on Tauri's async runtime: one task accepts connections on the per-user pipe or socket, and one task per client runs its session. Tool calls run on the blocking pool, like `on_worker`. A restart waits for the previous server to release the endpoint. Changing **Allow changes** does not restart it: each session watches the setting and sends its client `notifications/tools/list_changed`.
- Changes made by MCP clients go through `vault_service.rs`, which emits `p2p:crdt-update` for text and `vault:items-changed` for created, moved or deleted notes, so the open editor and the sidebar follow them.
- `lownotes-mcp` is a separate console process with a single-threaded Tokio runtime. It only relays bytes between the client's stdio and the app; it never opens the vault, so every read goes through the app's locks and recovery.

### Durability
Expand Down
31 changes: 27 additions & 4 deletions docs/MCP.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Connect AI apps over MCP

LowNotes can serve your notes to AI apps that speak the [Model Context Protocol](https://modelcontextprotocol.io/), such as Claude Desktop, Claude Code and Cursor. The app can search and read the vault open in LowNotes. It cannot create, change or delete notes.
LowNotes can serve your notes to AI apps that speak the [Model Context Protocol](https://modelcontextprotocol.io/), such as Claude Desktop, Claude Code and Cursor. The app can search and read the vault open in LowNotes. If you allow changes, it can also create, edit, move and delete notes there.

The server runs inside LowNotes, so the app must be running. It can stay in the system tray (**Settings → General → Keep running in the system tray**).

## Turn it on

1. Open **Settings → MCP server** and turn on **Turn on the MCP server**. The first time, this also shares the vault that is open.
2. Under **Shared vaults**, check the vaults AI apps may read. An app only ever reads the vault that is open in LowNotes, and only while it is checked.
3. Under **Connect an AI app**, copy the configuration for your app.
2. Under **Shared vaults**, check the vaults AI apps may use. An app only ever reaches the vault that is open in LowNotes, and only while it is checked.
3. Optionally turn on **Allow changes** so AI apps can also change notes (see [Changing notes](#changing-notes)). LowNotes asks you to confirm.
4. Under **Connect an AI app**, copy the configuration for your app.

### Claude Desktop

Expand Down Expand Up @@ -57,15 +58,36 @@ Each note is also available as a resource, `lownotes://note/{path}`. Paths insid

Search uses the same local keyword search as the assistant: words, phrases and headings, without embeddings.

### Changing notes

With **Allow changes** on, AI apps also get these tools:

| Tool | What it does |
| --- | --- |
| `create_note` | Creates a note with the given Markdown (up to 256 KiB), with any missing folders. It never overwrites a note. |
| `edit_note` | Replaces a passage, `old_text`, with `new_text` (each up to 256 KiB). The passage must appear exactly once, so the app has to read the note first. |
| `append_to_note` | Adds Markdown (up to 256 KiB) at the end of a note, on a new line. |
| `move_note` | Moves or renames a note. It keeps its identity, so paired devices see a move; wikilinks in other notes are not rewritten. |
| `delete_note` | Moves a note to the LowNotes trash, where you can restore it (**History and trash → Trash**). |

Changes go through the same path as typing in LowNotes: they are saved durably, an open editor shows them at once, the sidebar refreshes, and paired devices receive them. An edit only touches the passage it names, so text you type in the same note at the same time is kept. Folders and files that are not Markdown cannot be moved or deleted this way.

AI apps together can make at most 60 changes a minute; further calls are refused until the minute passes. The structural history records notes created, moved or deleted over MCP with the origin `mcp`.

The tools only appear while **Allow changes** is on. Apps that support tool list updates (`notifications/tools/list_changed`) see them appear and disappear at once; others after they reconnect. A call made after you turn it off is refused.

Turn on the AI app's own confirmation for these tools when it has one, so it asks you before each change.

## Privacy and safety

- **What leaves LowNotes.** Everything an AI app reads goes to that app and to the AI provider it uses, under that provider's terms. Share only the vaults you are comfortable sending.
- **Notes from other devices.** A paired device can sync any text, including text written to steer an AI ("ignore your instructions and…"). LowNotes labels note content as data and tells clients not to follow instructions inside it, but it cannot control the AI app. Be careful when the same app can also run commands, send messages or browse.
- **Changes are opt-in.** With **Allow changes** off, AI apps cannot change anything. With it on, steered text could also lead an app to edit, move or delete notes; deleted notes stay in the trash and earlier versions in the note's history on this computer, but paired devices receive the changes. Allow changes only for apps that ask you before they act.
- **Who can connect.** Only programs running as your user on this computer. `lownotes-mcp` presents an access token that LowNotes keeps in the system credential store; it never appears in the AI app's configuration or in LowNotes' interface.
- **Regenerate the token** (**Settings → MCP server → Regenerate token**) if you stop trusting an app that was connected. Every connected app is disconnected and has to reconnect.
- **Turn it off** at any time with the same switch; connected apps are disconnected at once.

The diagnostic log records which tool was called, how long it took and how large the answer was, never note content, search terms or the token.
The diagnostic log records which tool was called, how long it took and how large the answer was, never note content, note paths, search terms or the token. Changes are logged at the `info` level, so the log shows when an app changed notes.

## Troubleshooting

Expand All @@ -76,6 +98,7 @@ The diagnostic log records which tool was called, how long it took and how large
| LowNotes is not open | Start LowNotes; it can stay in the tray. |
| The LowNotes MCP server is off | Turn it on in **Settings → MCP server**. |
| The vault open in LowNotes is not shared | Check the vault under **Shared vaults**, or open a shared vault. |
| LowNotes lets AI apps read this vault but not change it | Turn on **Allow changes**, if you want the app to change notes. |
| LowNotes refused the token | The token was regenerated: restart or reconnect the AI app. |
| Could not read the MCP token | Unlock the system credential store (Keychain, Credential Manager or Secret Service). |

Expand Down
12 changes: 7 additions & 5 deletions docs/THREAT-MODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ This document describes what LowNotes protects, against whom, and the limits tha
- Remote providers receive the prompt and the note excerpts selected as context. Search sources receive the search query. Local providers (Ollama, LM Studio) keep this on the device.

### Local MCP clients and the models behind them
The MCP server ([MCP.md](MCP.md)) lets AI apps on the same computer read the vault open in LowNotes.
- Off by default. When on, it serves only the open vault, and only if that vault is shared in Settings. Every tool is read-only; paths inside `.lownotes/` and files that are not Markdown are refused.
The MCP server ([MCP.md](MCP.md)) lets AI apps on the same computer read the vault open in LowNotes and, if the user allows it, change its notes.
- Off by default. When on, it serves only the open vault, and only if that vault is shared in Settings. Paths inside `.lownotes/` and files that are not Markdown are refused.
- Tools are read-only unless the user turns on **Allow changes**, which is off by default and asks for confirmation. Only then are the change tools listed, and each call checks the setting again, so a client that kept an old tool list is refused. Changes use the interface's own paths: durable saves, structural intents, history and the trash. Edits must match one exact passage, creation never overwrites a note, moves and deletes refuse folders, and deleted notes go to the trash.
- The server listens on a per-user endpoint, never on the network: a named pipe whose DACL grants access to the current user's SID only and refuses remote clients, or a Unix socket (`0600`) in a folder only the user can enter (`0700`).
- Clients authenticate before any MCP traffic with a 256-bit token, compared in constant time. The token lives in the OS credential store and reaches neither the webview nor the client's configuration files: `lownotes-mcp` reads it from the store itself. Regenerating it disconnects every client.
- Pipe names are machine-wide, so `lownotes-mcp` checks that the process serving the pipe runs as the same Windows user before it sends the token. The pipe is created as the first instance, so LowNotes refuses to serve on a name another process already holds.
- Requests are bounded: 1 MiB per incoming line, 512 KiB of note text and 2 MiB per response, 8 clients at a time.
- Requests are bounded: 1 MiB per incoming line, 512 KiB of note text and 2 MiB per response, 8 clients at a time. Changes are bounded too: 256 KiB of text per call and 60 changes a minute across all clients. Creations, moves and deletes are recorded in the structural history with the origin `mcp`.
- What a client reads goes to that client and to its AI provider, as with the assistant's providers above.
- Notes synced by paired devices are untrusted text that can try to steer the model (prompt injection). Responses carry note text as JSON data, and the server tells clients to treat it as information, never as instructions; LowNotes cannot enforce how the client behaves.
- The diagnostic log records tool names, durations, sizes and error keys, never note content, search terms or the token.
- Notes synced by paired devices are untrusted text that can try to steer the model (prompt injection). Responses carry note text as JSON data, and the server tells clients to treat it as information, never as instructions, and never to change or delete notes because a note says so; LowNotes cannot enforce how the client behaves.
- The diagnostic log records tool names, durations, sizes and error keys, never note content, note paths, search terms or the token. Changes are logged at the `info` level.

### Update channel
- Updates are signed with the project's minisign key and verified before installation. Release assets have SHA-256 checksums, and the AUR recipe is published with real checksums.
Expand All @@ -63,4 +64,5 @@ The MCP server ([MCP.md](MCP.md)) lets AI apps on the same computer read the vau
- Anyone with access to the unlocked operating system account can read the vault files and, through the OS credential store, the stored secrets.
- Iroh discovery and relay services are third-party infrastructure.
- An MCP client that also has other tools (commands, messages, browsing) can be steered by injected note text into acting on it or sending it elsewhere. Keep the MCP server off, or share only vaults you trust, when an AI app has such tools.
- With **Allow changes** on, injected note text can also steer a client into editing, moving or deleting notes, and those changes sync to paired devices. Deleted notes can be restored from the local trash and edited notes from local history, but only on the device that kept them.
- Any program running as the same user can obtain the MCP token through the OS credential store, as with the other stored secrets.
16 changes: 10 additions & 6 deletions src-tauri/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use serde::{Deserialize, Serialize};

use crate::rag::ChatMessage;

const MAX_DRAFT_BYTES: usize = 256 * 1024;
/// Largest note text an AI may write in one draft, edit or append.
pub(crate) const MAX_DRAFT_BYTES: usize = 256 * 1024;
const MAX_RESPONSE_BYTES: usize = 1024 * 1024;

#[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -280,14 +281,15 @@ pub fn extract_edits(
}

/// Only creates new Markdown files. Existing notes are never overwritten, including on retries.
pub fn save_draft(root: &Path, draft: &NoteDraft) -> anyhow::Result<String> {
/// `origin` labels the creation in the structural history, such as "assistant" or "mcp".
pub fn save_draft(root: &Path, draft: &NoteDraft, origin: &str) -> anyhow::Result<String> {
validate_draft(draft)?;
crate::creation::create(
root,
&draft.path,
Some(&draft.content),
&crate::crdt::CrdtManager::new(),
"assistant",
origin,
)
}

Expand Down Expand Up @@ -502,11 +504,13 @@ mod tests {
let root = std::env::temp_dir().join(format!("lownotes-drafts-{}", rand::random::<u64>()));
fs::create_dir_all(&root).unwrap();
let note = draft("Python/Plano.md");
assert_eq!(save_draft(&root, &note).unwrap(), note.path);
assert_eq!(save_draft(&root, &note, "assistant").unwrap(), note.path);
let mut changed = note.clone();
changed.content = "overwritten".into();
assert_eq!(
save_draft(&root, &changed).unwrap_err().to_string(),
save_draft(&root, &changed, "assistant")
.unwrap_err()
.to_string(),
"errors.noteExists"
);
assert_eq!(
Expand Down Expand Up @@ -585,7 +589,7 @@ mod tests {
let root =
std::env::temp_dir().join(format!("lownotes-provider-{}", rand::random::<u64>()));
fs::create_dir_all(&root).unwrap();
save_draft(&root, &drafts[0]).unwrap();
save_draft(&root, &drafts[0], "assistant").unwrap();
assert!(fs::read_to_string(root.join("Python/Plano.md"))
.unwrap()
.contains("Praticar funções"));
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ pub struct McpSettings {
pub enabled: bool,
/// Vaults MCP clients may read; only the active one is served.
pub vault_ids: Vec<String>,
/// MCP clients may also create, edit, move and delete notes in the shared
/// vaults. Off by default: a client's model can be steered by note text.
pub allow_changes: bool,
/// Authenticates the bridge that MCP clients launch. Kept in the OS
/// credential store and never sent to the webview.
pub token: String,
Expand Down
Loading
Loading