Repository navigation
feat(mcp): write tools behind an Allow changes switch - #127
Open
FabioHAraujo wants to merge 1 commit into
Open
FabioHAraujo wants to merge 1 commit into
FabioHAraujo wants to merge 1 commit into
Conversation
MCP clients can now create, edit, append to, move and delete notes in the shared vault when the new Allow changes setting is on. It is off by default and asks for confirmation when turned on. - create_note, edit_note (one exact passage), append_to_note, move_note and delete_note (to the trash) reuse the interface's paths: durable saves, structural intents, history and the trash. - The change tools are listed only while changes are allowed; sessions send notifications/tools/list_changed when the setting flips, and every call checks it again. - The open editor receives p2p:crdt-update and the sidebar reloads on the new vault:items-changed event; peers receive the changes as usual. - Creations, moves and deletes are recorded with the origin "mcp"; changes are limited to 256 KiB per call and 60 a minute across clients. - Docs: MCP guide, threat model, architecture, README and changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #105.
MCP clients (Claude Desktop, Claude Code, Cursor) can now change notes in the shared vault, not only read them. Changes stay off until the user turns on Settings → MCP server → Allow changes, which asks for confirmation.
Tools
create_notevault_service::save_draft→creation::create; never overwrites; adds.mdand missing foldersedit_notecrdt.apply_note_edit;old_textmust match exactly onceappend_to_notecrdt.append_note_text, sharing the edit transaction (change_note_text)move_notestructural::rename; keeps the note's identitydelete_notecatalog_sync::delete; the note goes to the trashScope change from #105: the issue ruled out move and delete. They are included by the maintainer's decision; see the comment on #105. Both refuse folders, are annotated
destructiveHint, and keep the note recoverable.How it fits
McpSettings.allow_changes(serde defaultfalse). The change tools are filtered out oftools/listwhile it is off, andwritable_vaultchecks it again on every call, so a client with a stale list is refused with a clear message.McpServicekeeps awatchof the setting; each session sendsnotifications/tools/list_changedwhen it flips (capabilitytools.listChanged). Toggling it does not restart the server.vault_service::VaultEvents(implemented byAppHandle, recorded in tests) emitsp2p:crdt-updatefor text changes and the newvault:items-changedfor created, moved or deleted notes;+page.sveltereloads the list for the open vault.ai_apply_edituses the same trait.mcp(the catalog is the only place an origin is recorded; history and wikilink projections have no origin field). Edits and appends reuse the draft limit (256 KiB); a resulting note overMAX_NOTE_BYTESis refused; at most 60 changes a minute across all clients. No protocol change, so older peers keep syncing.infowith the tool name and duration, never content or paths.Tests
mcp::tests::changes_notes_only_while_the_user_allows_it: a real client over the pipe or socket. It covers changes being refused while off, thelist_changednotice, every tool's success and error paths, the interface events, the trash, themcpauthor, and turning changes off again.changes_are_limited_per_minute_across_clientsandnew_note_paths_get_a_markdown_extension.vault:items-changedreloading only the open vault.Local run on Windows: the full AGENTS.md list passes (
cargo fmt, clippy-D warnings, 203 Rust tests,svelte-check, 123 bun tests, script tests, build, 50 Playwright tests). The Unix socket path compiles only on CI. Not yet tried against a live Claude Desktop or Claude Code session.