Repository navigation
Conversation
A shared knowledge base can be read by several agents while writes stay with a reviewed process. Until now every write tool was always offered; only bm_project_delete could be hidden. Add a `read_only` setting (env `BASIC_MEMORY_READ_ONLY`, default off). When it is on, the MCP server lists only the tools annotated readOnlyHint: true, and the hidden ones cannot be called. Indexing keeps running, so notes written on disk still appear in search. The write tools carry a WRITES_TAG, and a test asserts the tag set equals the set of tools annotated readOnlyHint: false, so a tool added later cannot silently stay reachable in read-only mode. The two visibility flags are now composed into a single decision. Marks are "last appended wins", so the earlier enable/disable mark per flag re-shown bm_project_delete whenever read-only mode was turned back off. Refs basicmachines-co#2134 Signed-off-by: Goldloli <[email protected]>
|
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 927bbfaae9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Hiding the write tools was only half the answer: the instructions still told every connected model to save with bm_write, and the getting_started prompt still walked a new user through creating a first note with it, so both pointed at calls the server now refuses. The instructions switch with the same flag that hides the tools, and the offline prompt takes a read-only branch. Both are pinned by tests that fail when the switch is removed.
|
Right on both counts — fixed in 94eb553. The instructions switch with the mode.
Two regression tests, both verified to fail without the change:
The one failure is |
|
Thank you for putting this together — this directly solves a real multi-harness pain point for us. We run one primary MCP client with full write + live indexing access alongside two secondary read-only MCP clients (different harnesses pointing at the same SQLite database and markdown vault). Today we have to maintain separate per-client One subtle operational detail worth calling out in the docs (or pairing with an option / CLI flag): Because
In our setup, pairing (Also a quick heads-up: the |
What this changes
Adds a
read_onlysetting (envBASIC_MEMORY_READ_ONLY, default off). With it on, the MCP server offers only the tools annotatedreadOnlyHint: true, and the hidden write tools cannot be called. Indexing keeps running, so notes written on disk by another process still show up in search.Hidden in read-only mode:
bm_write,bm_edit,bm_move,bm_delete,bm_project_create. Everything else (bm_read,bm_search,bm_context,bm_list,bm_find,bm_man,bm_project_list,bm_recent,bm_schema_*) stays listed.Why
A shared Basic Memory project is often read by several agents while all writes go through a separate reviewed process. Today every write tool is always offered, and only
bm_project_deletecan be hidden, so getting a read-only tool set needs a filtering proxy in front of the server. Client-side deny lists differ per harness and have to be repeated for each one.Fixes #2134
How it works
BasicMemoryConfig.read_onlyis a plainboolfield, so pydantic-settings already rejects values it cannot parse.BASIC_MEMORY_READ_ONLY=maybefails at startup instead of silently leaving read-only off.WRITES_TAG.set_read_only_visibilityhides by that tag, on the local provider, like the existingset_project_delete_visibility.test_writes_tag_matches_read_only_annotationsasserts the tagged set equals the set of tools annotatedreadOnlyHint: false. A write tool added later without the tag fails that test instead of staying reachable in read-only mode.read_only,enable_project_delete) are now composed into one decision. FastMCP visibility marks are "last appended wins", so marking writes visible again turnedbm_project_deleteback on even thoughenable_project_deletewas still off. Both flags now recompute the hidden set together and re-mark the complement by name.Testing
Installed the dev environment in an isolated venv (
uv sync, Python 3.14) and ran, withBASIC_MEMORY_CONFIG_DIRpointed at a temp dir:The one failure is
tests/mcp/test_tool_bm_search_query.py::test_since_filters_by_update_time, and it fails the same way on the unmodifiedmaincheckout in this environment (assert [] == ['Recent Note']), so it is not caused by this change.Static checks, on the changed files and then on the whole tree:
Mutation checks, each on the changed code, to confirm the new tests are load-bearing:
read_onlyflag when computing the hidden settest_read_only_mode_hides_and_blocks_write_toolsfailstest_project_delete_is_hidden_by_defaultWRITES_TAGfrombm_deletetest_writes_tag_matches_read_only_annotationsfailsAll three were reverted before committing.
Behaviour
BASIC_MEMORY_READ_ONLYunset orfalse: unchanged, all tools listed.BASIC_MEMORY_READ_ONLY=true: write tools are not listed, and calling one raisesNotFoundError— the same path a retired tool takes.enable_project_deletekeeps working independently.Risk
Small and opt-in: the default is off, and no tool behaviour changes. The one behavioural change for existing users is that
set_project_delete_visibilitynow also re-marks the visible tools by name;test_project_delete_is_hidden_by_defaultandtest_config_flag_lists_project_delete_through_lifespancover that path.