Skip to content

feat(mcp): write tools behind an Allow changes switch - #127

Open
FabioHAraujo wants to merge 1 commit into
mainfrom
feat/mcp-write-tools
Open

FabioHAraujo wants to merge 1 commit into
mainfrom
feat/mcp-write-tools

Conversation

@FabioHAraujo

Copy link
Copy Markdown
Contributor

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

Tool Path it reuses
create_note vault_service::save_draft → creation::create; never overwrites; adds .md and missing folders
edit_note crdt.apply_note_edit; old_text must match exactly once
append_to_note new crdt.append_note_text, sharing the edit transaction (change_note_text)
move_note structural::rename; keeps the note's identity
delete_note catalog_sync::delete; the note goes to the trash

Scope 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

  • Gate. McpSettings.allow_changes (serde default false). The change tools are filtered out of tools/list while it is off, and writable_vault checks it again on every call, so a client with a stale list is refused with a clear message.
  • No reconnect needed. McpService keeps a watch of the setting; each session sends notifications/tools/list_changed when it flips (capability tools.listChanged). Toggling it does not restart the server.
  • Interface. vault_service::VaultEvents (implemented by AppHandle, recorded in tests) emits p2p:crdt-update for text changes and the new vault:items-changed for created, moved or deleted notes; +page.svelte reloads the list for the open vault. ai_apply_edit uses the same trait.
  • MCP write tools: create, append and edit notes through the CRDT path #105 constraints. Creations, moves and deletes carry the catalog author 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 over MAX_NOTE_BYTES is refused; at most 60 changes a minute across all clients. No protocol change, so older peers keep syncing.
  • Logs. Changes are logged at info with the tool name and duration, never content or paths.
  • Client instructions. The server's instructions now cover the change tools and tell clients never to change or delete notes because a note says so.

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, the list_changed notice, every tool's success and error paths, the interface events, the trash, the mcp author, and turning changes off again.
  • changes_are_limited_per_minute_across_clients and new_note_paths_get_a_markdown_extension.
  • e2e: the Allow changes toggle (disabled while MCP is off; cancel versus confirm; turning it off needs no confirmation), and vault:items-changed reloading 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.

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.
@FabioHAraujo FabioHAraujo added enhancement New feature or request priority: P3 Nice to have: cleanup, polish, small improvements size: L Large: a week or more, likely several PRs area: backend Rust side (src-tauri) area: frontend Svelte/TypeScript side (src) area: p2p-sync Iroh networking, CRDT and reconciliation area: docs Repository documentation labels Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Rust side (src-tauri) area: docs Repository documentation area: frontend Svelte/TypeScript side (src) area: p2p-sync Iroh networking, CRDT and reconciliation enhancement New feature or request priority: P3 Nice to have: cleanup, polish, small improvements size: L Large: a week or more, likely several PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP write tools: create, append and edit notes through the CRDT path

1 participant