Skip to content

fix(mcp): refuse config and ack writes in read-only mode (#2103) - #2126

Merged
igorls merged 2 commits into
developfrom
fix/2103-onto-develop
Aug 2, 2026
Merged

fix(mcp): refuse config and ack writes in read-only mode (#2103)#2126
igorls merged 2 commits into
developfrom
fix/2103-onto-develop

Conversation

@igorls

@igorls igorls commented Aug 2, 2026

Copy link
Copy Markdown
Member

Summary

Conflict-resolved merge of #2103 onto current develop.

Closes #2103.

Test plan

  • Focused RO/lease tests pass

mvalentsev and others added 2 commits July 29, 2026 19:32
Read-only gated on _MUTATING_TOOLS, which is the palace-write set the
peer-writer lease consults to decide which calls need the palace mine
lock. Two tools change state without touching the palace, so they are
correctly absent from that set and were served on a --read-only server
anyway: mempalace_hook_settings rewrites ~/.mempalace/config.json via
MempalaceConfig.set_hook_setting, and mempalace_memories_filed_away
unlinks ~/.mempalace/hook_state/last_checkpoint on both branches.

Add _READ_ONLY_REFUSED_TOOLS and point the dispatch gate and the
tools/list filter at it. _MUTATING_TOOLS and the peer-writer path are
unchanged: adding the two names there instead would put a config-only
tool under the palace lease, so a server that lost the lease to a peer
would answer -32001 for a call the lease has no say over.

mempalace_reconnect stays reachable on purpose and the comment records
why, since clearing ChromaBackend._quarantined_paths lets the reopen
rename a segment directory. The two --read-only help strings and the
matching row in the remote-server guide said "the mutating tools",
which now names the narrower set.
@igorls
igorls requested a review from milla-jovovich as a code owner August 2, 2026 08:26
Copilot AI review requested due to automatic review settings August 2, 2026 08:26
@igorls
igorls merged commit 6ec2030 into develop Aug 2, 2026
8 of 9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens MCP --read-only behavior so the server refuses additional state-changing tools that don’t mutate the palace DB (config writes and hook checkpoint-ack deletion), aligning read-only semantics with the daemon’s write classification and adding targeted regression tests.

Changes:

  • Add _READ_ONLY_REFUSED_TOOLS and gate both tools/list and dispatch on it (instead of only _MUTATING_TOOLS).
  • Refuse mempalace_hook_settings and mempalace_memories_filed_away in read-only mode, while keeping the peer-writer lease logic based on _MUTATING_TOOLS.
  • Expand tests to cover the new read-only refusals and ensure parity with service.WRITE_TOOLS.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
website/guide/remote-server.md Updates read-only flag description in the remote server guide.
tests/test_mcp_server.py Adds unit tests asserting the refused set, daemon parity, and lease separation.
tests/test_mcp_http_transport.py Adds HTTP-level tests proving config/ack writes are blocked in read-only mode.
mempalace/mcp_server.py Introduces _READ_ONLY_REFUSED_TOOLS and uses it for read-only list/dispatch gating.
mempalace/cli.py Updates CLI help text for --read-only.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mempalace/mcp_server.py
Comment on lines +293 to +294
help="Serve a read-only tool surface: the tools that change state are hidden "
"from tools/list and refused at dispatch (env MEMPALACE_MCP_READ_ONLY)",
Comment thread mempalace/cli.py
"--read-only",
action="store_true",
help="Expose recall only: mutating tools are hidden and refused",
help="Expose recall only: tools that change state are hidden and refused",
| `--backend` | config/env | Storage backend (e.g. `qdrant`) |
| `--tls-cert` / `--tls-key` | _(none)_ | PEM cert + key to terminate **TLS natively** (server speaks `https`) |
| `--read-only` | off | Expose recall only — the mutating tools are hidden and refused |
| `--read-only` | off | Expose recall only — the tools that change state are hidden and refused |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants