frugal-memory 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sebastian Woratsch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,315 @@
1
+ Metadata-Version: 2.4
2
+ Name: frugal-memory
3
+ Version: 0.1.0
4
+ Summary: A memory for AI assistants that is just a SQLite file: full-text search over MCP, no vector store, no embeddings, no external service.
5
+ Author: Sebastian Woratsch
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/komakeule57-maker/frugal-memory
8
+ Project-URL: Measurements, https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md
9
+ Project-URL: Issues, https://github.com/komakeule57-maker/frugal-memory/issues
10
+ Keywords: mcp,memory,sqlite,fts5,claude,agent,full-text-search
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: German
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Database
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: mcp>=2.2.0
23
+ Dynamic: license-file
24
+
25
+ # frugal-memory
26
+
27
+ A persistent memory for AI assistants that is just a SQLite file — and
28
+ costs about a fifth of what reading markdown notes does.
29
+
30
+ No vector store, no embeddings, no external service, no API key. Python,
31
+ SQLite with FTS5, stdio — the only dependency is the official `mcp` SDK.
32
+ Nothing leaves your machine unless you explicitly turn on the optional
33
+ fact check.
34
+
35
+ Measured over 275 real questions from 89 working sessions: **2,359 tokens
36
+ per answered question, against 11,319** for the usual one markdown file
37
+ per fact, found with `grep` and read whole. The gap grows as the memory
38
+ does, because every answer here is capped and `grep` is not. All figures
39
+ come from one installation, and the docs say where one did not hold up.
40
+
41
+ ## Why
42
+
43
+ An assistant's memory usually fails in one of two ways: it is a pile of
44
+ markdown files that has to be read whole to be searched, or it is a
45
+ vector database that answers *that* something matched but never *why*.
46
+
47
+ This one is a ranked full-text index over short entries, with two things
48
+ bolted on that turn a note pile into a memory: entries are filed on two
49
+ axes — **where** it belongs (project) and **what kind** of knowledge it is
50
+ (pitfall, decision, measurement, …) — and when you write something down,
51
+ the tool tells you which existing entries it overlaps with, so
52
+ contradictions surface instead of quietly piling up.
53
+
54
+ ## Features
55
+
56
+ - **Capped, calculable answers** — a search returns eight preview lines
57
+ of about 1.2 KB in total instead of 4.2 KB of full text; `zeige` then
58
+ fetches the entries you pick, about 6,000 characters per call unless
59
+ you ask for everything. The worst case is known before you ask.
60
+ - **It learns from its own failures** — when a search is followed by
61
+ fetching an entry, that pair is remembered. Ask the same thing again and
62
+ the entry that answered last time comes first. Word-for-word repeats
63
+ only, and the header says when it fired.
64
+ - **Two filing axes** — a free-text project tag and a closed, enforced
65
+ vocabulary of knowledge kinds. Chronicle entries are hidden from search
66
+ by default, but the header always says how many were held back.
67
+ - **Duplicate and contradiction hints** — `remember` reports similar
68
+ existing entries and which numbers changed, so you can supersede
69
+ instead of accumulate.
70
+ - **Nothing is ever deleted** — superseded entries drop out of the default
71
+ view and stay findable, with a note on why and by what.
72
+ - **Browsing, not just searching** — `themen()` lists projects and a
73
+ project's newest title lines for when you have forgotten the words to
74
+ search for. Capped like everything else: one page, and a line saying how
75
+ to get the rest.
76
+ - **Project-bound in use, not in search** — the usual question is asked
77
+ inside one project, with `marke=`. That filter is hard, so when the best
78
+ match lies outside the project, `recall` names it instead of leaving you
79
+ with a plausible-looking list of the wrong entries.
80
+ - **Opt-in second opinion** — optionally ask any OpenAI-compatible model
81
+ whether two entries contradict each other or just supersede one another.
82
+ - **German by default, English on request** — tool names, messages and
83
+ kinds are German; `MEMORY_LANG=en` switches all of it. The search also
84
+ matches inflected forms and compound parts ("Rangliste" finds
85
+ "Ranglisten"). Measured, that rarely changes the answer: the plain
86
+ any-term stage of the search already finds what the stems would add
87
+ ([details](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md#the-cascade-against-plain-or)).
88
+
89
+ ## Requirements
90
+
91
+ - Python 3.11+
92
+ - The `mcp` SDK (`requirements.txt`, that's the whole list)
93
+ - SQLite with FTS5 — included in standard CPython builds
94
+ - Optional, for the fact check only: any OpenAI-compatible endpoint
95
+
96
+ ## Setup
97
+
98
+ From PyPI, as a command in its own environment:
99
+
100
+ ```bash
101
+ pipx install frugal-memory # or: uv tool install frugal-memory
102
+
103
+ claude mcp add memory -s user -- frugal-memory
104
+ ```
105
+
106
+ The database is created on first use at
107
+ `~/.local/share/frugal-memory/memory.db` (`$XDG_DATA_HOME` if set).
108
+ `frugal-memory-nachziehen` is the upkeep script described in
109
+ [DESIGN.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/DESIGN.md).
110
+
111
+ Or from a checkout of this repository:
112
+
113
+ ```bash
114
+ python3 -m venv .venv
115
+ .venv/bin/pip install -r requirements.txt
116
+
117
+ claude mcp add memory -s user -- \
118
+ /path/to/frugal-memory/.venv/bin/python \
119
+ /path/to/frugal-memory/memory_server.py
120
+ ```
121
+
122
+ Here the database is created as `memory.db` next to the script. Either way,
123
+ `MEMORY_DB=/some/path.db` puts it somewhere else.
124
+
125
+ `-s user` makes the server available in all projects; the entry ends up in
126
+ `~/.claude.json`. Restart Claude Code afterward — MCP servers are only
127
+ loaded at startup. The tools are then called `mcp__memory__recall` and
128
+ `mcp__memory__remember`.
129
+
130
+ For Claude Desktop, use `~/.config/Claude/claude_desktop_config.json`
131
+ instead:
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "memory": {
137
+ "command": "/path/to/frugal-memory/.venv/bin/python",
138
+ "args": ["/path/to/frugal-memory/memory_server.py"]
139
+ }
140
+ }
141
+ }
142
+ ```
143
+
144
+ **One rule matters more than any setting: one fact per call, not one
145
+ document.** `recall` returns whole entries — store a 180 KB file as a
146
+ single entry and you get it back as a single hit, having gained nothing.
147
+
148
+ ### Teaching the agent how to use it
149
+
150
+ The tools alone don't tell an agent the working rules: search before
151
+ reading files, `recall` → `zeige`, exactly one kind per entry, supersede
152
+ instead of accumulate, retry in the other language. Those live in a skill
153
+ that ships with the repo (not with the PyPI package):
154
+
155
+ ```bash
156
+ cp -r skills/frugal-memory ~/.claude/skills/
157
+ ```
158
+
159
+ Claude Code loads its full text only when the memory comes up; until then
160
+ only the one-line description sits in context.
161
+
162
+ ### Reading another machine's memory
163
+
164
+ Each machine keeps its own memory, and each numbers its entries from 1. A
165
+ session on machine A can read the memory of machine B over SSH — the server
166
+ runs on B, next to its file; the database itself never crosses the network:
167
+
168
+ ```
169
+ claude mcp add memory-b -s project -- \
170
+ ssh b /path/to/frugal-memory/.venv/bin/python \
171
+ /path/to/frugal-memory/memory_server.py --gast
172
+ ```
173
+
174
+ `--gast` (guest) means three things:
175
+
176
+ - **Read-only.** The file is opened with `mode=ro`, and only `recall`,
177
+ `zeige` and `themen` are offered. The writing tools are gone, and so are
178
+ `verdichten` and `pruefe`: upkeep belongs to the owner, who can act on it. A guest's searches do
179
+ not feed the owner's search feedback either, and a guest never migrates
180
+ the schema.
181
+ - **Every id carries the memory's name:** `b#72`, not `#72`. The name is the
182
+ host name in lower case; `MEMORY_NAME` overrides it.
183
+ - **A named id is checked, in both modes.** `zeige("b#72")` asked of any
184
+ memory other than `b` is refused instead of quietly returning that
185
+ memory's own #72. Bare ids (`72`, `#72`) mean the memory being asked.
186
+
187
+ `-s project` keeps the three extra tool definitions out of sessions that do
188
+ not need them. The tools are then called `mcp__memory-b__recall` and so on.
189
+
190
+ ## The Eight Tools
191
+
192
+ | | |
193
+ |---|---|
194
+ | `remember(text, tags, art, ersetzt)` | store an entry; reports similar existing ones and what it would supersede |
195
+ | `recall(query, limit, art, marke, …)` | ranked full-text search, preview by default; under `marke=` it names a better match outside the project |
196
+ | `zeige(ids, voll)` | full text of specific entries, about 6000 characters per call; what doesn't fit is listed with the call that fetches it |
197
+ | `themen(marke, limit, seite, alle)` | browse: which projects exist, or one project's title lines, newest first, a page at a time |
198
+ | `vergessen(ids, grund)` | mark as outdated — never deletes |
199
+ | `einordnen(ids, art)` | assign the knowledge kind of existing entries |
200
+ | `verdichten(marke, art, …)` | find groups of entries that say much the same thing |
201
+ | `pruefe(ids)` | opt-in: have a language model judge contradiction vs. newer state |
202
+
203
+ Full reference with parameters and behavior: [docs/TOOLS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/TOOLS.md).
204
+ With `MEMORY_LANG=en` the same tools come with English names and parameters,
205
+ see [A Note on Language](#a-note-on-language).
206
+
207
+ ## Some Numbers
208
+
209
+ Measured on one real dataset that grew from ~900 to ~1,900 entries along
210
+ the way — evidence from one installation, not a benchmark:
211
+
212
+ - **4.8× cheaper than reading markdown files**, in real tokens, over 275
213
+ real questions (2,359 vs. 11,319 per question). The gap grows with the
214
+ dataset and with file size, because reading a file is all-or-nothing:
215
+ one question against a 188 KB project file costs 94,152 tokens.
216
+ - **82.3 % Recall@10** against the public LoCoMo dataset with a session as
217
+ the unit, **45.1 %** with a single dialogue turn — untuned, first run, at
218
+ 2 ms and 2.7 KB per query.
219
+ - **73 % smaller returns** from the preview, with a calculable worst case.
220
+ - **−23 % expected characters per question** from the feedback loop, at
221
+ 84 % vs. 73 % first-round hit rate, measured over 164 questions from 30
222
+ real sessions in a time-ordered replay — a pair only ever helps *later*
223
+ questions, never itself. 19 questions gained, none lost.
224
+ - **53 % → 64 %** hit rate on 47 real reformulation chains from a one-line
225
+ ranking fix — found by measuring where real search sessions had failed,
226
+ not by guessing. On today's dataset the same fix also *costs* 3 of the 117
227
+ questions that already worked, so the net is +2 of 164.
228
+ - **93 % of the dataset belongs to a project** (1,777 of 1,907 entries),
229
+ and that is how the tool is used. Search itself does not care: general
230
+ knowledge is found as well as project knowledge (92 % vs. 96 %, a tie
231
+ under the 10 % rule). What the project filter buys is precision for
232
+ short questions — 97 % vs. 85 % found at about three words. What it
233
+ costs is everything outside the project: 40 questions about general
234
+ knowledge, asked under 22 project tags, found **0 of 880**. `recall` now
235
+ names the better match outside the tag in 82 % of those cases, and in
236
+ 70 % that line already is the entry sought; on real project questions
237
+ it fires in 7–16 %.
238
+ - **−83 % for a project's title index, −34 % for fetching eight full
239
+ texts**, from capping `themen` and `zeige`. On 110 project questions the
240
+ cap cost not one answer.
241
+
242
+ Where a measurement did not survive a larger sample, it says so:
243
+ [docs/MEASUREMENTS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md), with the raw reports in
244
+ [`messung/`](https://github.com/komakeule57-maker/frugal-memory/tree/main/messung/). The ranking figure above was corrected twice —
245
+ see [The Ranking Fix, Corrected Twice](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md#the-ranking-fix-corrected-twice).
246
+
247
+ ## Documentation
248
+
249
+ | | |
250
+ |---|---|
251
+ | [docs/TOOLS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/TOOLS.md) | all eight tools in detail |
252
+ | [docs/DESIGN.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/DESIGN.md) | the two axes, the morphology, the database schema, and what was left out on purpose |
253
+ | [docs/MEASUREMENTS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md) | what was measured, and the known limitations |
254
+ | [docs/FACTCHECK.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/FACTCHECK.md) | the opt-in fact check: setup, what it can and cannot do |
255
+ | [docs/IMPORT.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/IMPORT.md) | importing an existing folder of notes, and the damage that did |
256
+ | [`messung/`](https://github.com/komakeule57-maker/frugal-memory/tree/main/messung/) | the eight underlying measurement reports (mostly German) |
257
+
258
+ ## A Note on Language
259
+
260
+ German is the default: tool names, status messages and the kind vocabulary
261
+ (`schnittstelle`, `fallstrick`, `entscheidung`, `messwert`, `arbeitsweise`,
262
+ `verlauf`, `gemischt`) are German, and the search stems German and splits
263
+ German compounds.
264
+
265
+ **English mode:** start the server with `MEMORY_LANG=en`. Then
266
+
267
+ - the tools are `remember(text, tags, kind, supersedes)`,
268
+ `recall(query, limit, kind, tag, full, include_superseded)`, `show(ids)`,
269
+ `topics(tag, limit)`, `forget(ids, reason)`, `classify(ids, kind)`,
270
+ `consolidate(tag, kind, threshold, groups)` and `check(ids)`,
271
+ - the kinds are `interface`, `pitfall`, `decision`, `measurement`,
272
+ `workflow`, `history`, `unsorted`,
273
+ - every message is English,
274
+ - the search uses a small English suffix stemmer ("configured" finds
275
+ "configuring") instead of the German one, and does not split compounds.
276
+
277
+ The database itself does not change: kinds are always stored under their
278
+ German names and translated at the border, and German kind names are
279
+ accepted in both modes. What does change is the stem index, so the file
280
+ records the language it was built in and the server refuses to open it
281
+ with the other one. To switch an existing memory, back it up and run
282
+ `MEMORY_LANG=en python3 nachziehen.py` once.
283
+
284
+ Not covered by the switch: the fact-check prompt stays German (it is
285
+ calibrated word for word, and adding one sentence once halved its
286
+ accuracy; only its verdicts are shown in English), and so do the import
287
+ script and the measurement reports. The English stemmer is new and has
288
+ **not** been measured on real questions the way the German search has.
289
+
290
+ ## Files
291
+
292
+ | | |
293
+ |---|---|
294
+ | `memory_server.py` | MCP server, eight tools, search cascade, schema, migrations |
295
+ | `morphologie.py` | stemmer and compound splitter (German; small English stemmer for `MEMORY_LANG=en`) |
296
+ | `werkzeuge_en.py` | the English tool surface for `MEMORY_LANG=en` |
297
+ | `texte_en.py` | English messages, keyed by the German text |
298
+ | `nachziehen.py` | recomputes `stems`/`teile` and refreshes the tag directory |
299
+ | `faktencheck.py` | opt-in second opinion via any OpenAI-compatible model (off unless configured) |
300
+ | `pruefstand_fc.py` | measures the fact check against gold labels from the dataset |
301
+ | `pruefpaare_gebaut.json` | the hand-built and hand-found contradiction pairs |
302
+ | `import_memos.py` | import a file-based memory *(one-off; see docs/IMPORT.md)* |
303
+ | `test_memory.py` | regression net, one case per pitfall (no pytest) |
304
+ | `skills/frugal-memory/SKILL.md` | working rules for the agent, as a Claude Code skill |
305
+ | `requirements.txt` | just `mcp` |
306
+ | `memory.db` | the database — created on first use, never committed |
307
+
308
+ `messung/` keeps the eight measurement **reports**. The scripts that
309
+ produced them and their raw data are not included: they only run against
310
+ the author's own dataset, and the raw data is a verbatim transcript of
311
+ real working sessions.
312
+
313
+ ## License
314
+
315
+ MIT — see [LICENSE](https://github.com/komakeule57-maker/frugal-memory/blob/main/LICENSE).
@@ -0,0 +1,291 @@
1
+ # frugal-memory
2
+
3
+ A persistent memory for AI assistants that is just a SQLite file — and
4
+ costs about a fifth of what reading markdown notes does.
5
+
6
+ No vector store, no embeddings, no external service, no API key. Python,
7
+ SQLite with FTS5, stdio — the only dependency is the official `mcp` SDK.
8
+ Nothing leaves your machine unless you explicitly turn on the optional
9
+ fact check.
10
+
11
+ Measured over 275 real questions from 89 working sessions: **2,359 tokens
12
+ per answered question, against 11,319** for the usual one markdown file
13
+ per fact, found with `grep` and read whole. The gap grows as the memory
14
+ does, because every answer here is capped and `grep` is not. All figures
15
+ come from one installation, and the docs say where one did not hold up.
16
+
17
+ ## Why
18
+
19
+ An assistant's memory usually fails in one of two ways: it is a pile of
20
+ markdown files that has to be read whole to be searched, or it is a
21
+ vector database that answers *that* something matched but never *why*.
22
+
23
+ This one is a ranked full-text index over short entries, with two things
24
+ bolted on that turn a note pile into a memory: entries are filed on two
25
+ axes — **where** it belongs (project) and **what kind** of knowledge it is
26
+ (pitfall, decision, measurement, …) — and when you write something down,
27
+ the tool tells you which existing entries it overlaps with, so
28
+ contradictions surface instead of quietly piling up.
29
+
30
+ ## Features
31
+
32
+ - **Capped, calculable answers** — a search returns eight preview lines
33
+ of about 1.2 KB in total instead of 4.2 KB of full text; `zeige` then
34
+ fetches the entries you pick, about 6,000 characters per call unless
35
+ you ask for everything. The worst case is known before you ask.
36
+ - **It learns from its own failures** — when a search is followed by
37
+ fetching an entry, that pair is remembered. Ask the same thing again and
38
+ the entry that answered last time comes first. Word-for-word repeats
39
+ only, and the header says when it fired.
40
+ - **Two filing axes** — a free-text project tag and a closed, enforced
41
+ vocabulary of knowledge kinds. Chronicle entries are hidden from search
42
+ by default, but the header always says how many were held back.
43
+ - **Duplicate and contradiction hints** — `remember` reports similar
44
+ existing entries and which numbers changed, so you can supersede
45
+ instead of accumulate.
46
+ - **Nothing is ever deleted** — superseded entries drop out of the default
47
+ view and stay findable, with a note on why and by what.
48
+ - **Browsing, not just searching** — `themen()` lists projects and a
49
+ project's newest title lines for when you have forgotten the words to
50
+ search for. Capped like everything else: one page, and a line saying how
51
+ to get the rest.
52
+ - **Project-bound in use, not in search** — the usual question is asked
53
+ inside one project, with `marke=`. That filter is hard, so when the best
54
+ match lies outside the project, `recall` names it instead of leaving you
55
+ with a plausible-looking list of the wrong entries.
56
+ - **Opt-in second opinion** — optionally ask any OpenAI-compatible model
57
+ whether two entries contradict each other or just supersede one another.
58
+ - **German by default, English on request** — tool names, messages and
59
+ kinds are German; `MEMORY_LANG=en` switches all of it. The search also
60
+ matches inflected forms and compound parts ("Rangliste" finds
61
+ "Ranglisten"). Measured, that rarely changes the answer: the plain
62
+ any-term stage of the search already finds what the stems would add
63
+ ([details](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md#the-cascade-against-plain-or)).
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.11+
68
+ - The `mcp` SDK (`requirements.txt`, that's the whole list)
69
+ - SQLite with FTS5 — included in standard CPython builds
70
+ - Optional, for the fact check only: any OpenAI-compatible endpoint
71
+
72
+ ## Setup
73
+
74
+ From PyPI, as a command in its own environment:
75
+
76
+ ```bash
77
+ pipx install frugal-memory # or: uv tool install frugal-memory
78
+
79
+ claude mcp add memory -s user -- frugal-memory
80
+ ```
81
+
82
+ The database is created on first use at
83
+ `~/.local/share/frugal-memory/memory.db` (`$XDG_DATA_HOME` if set).
84
+ `frugal-memory-nachziehen` is the upkeep script described in
85
+ [DESIGN.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/DESIGN.md).
86
+
87
+ Or from a checkout of this repository:
88
+
89
+ ```bash
90
+ python3 -m venv .venv
91
+ .venv/bin/pip install -r requirements.txt
92
+
93
+ claude mcp add memory -s user -- \
94
+ /path/to/frugal-memory/.venv/bin/python \
95
+ /path/to/frugal-memory/memory_server.py
96
+ ```
97
+
98
+ Here the database is created as `memory.db` next to the script. Either way,
99
+ `MEMORY_DB=/some/path.db` puts it somewhere else.
100
+
101
+ `-s user` makes the server available in all projects; the entry ends up in
102
+ `~/.claude.json`. Restart Claude Code afterward — MCP servers are only
103
+ loaded at startup. The tools are then called `mcp__memory__recall` and
104
+ `mcp__memory__remember`.
105
+
106
+ For Claude Desktop, use `~/.config/Claude/claude_desktop_config.json`
107
+ instead:
108
+
109
+ ```json
110
+ {
111
+ "mcpServers": {
112
+ "memory": {
113
+ "command": "/path/to/frugal-memory/.venv/bin/python",
114
+ "args": ["/path/to/frugal-memory/memory_server.py"]
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ **One rule matters more than any setting: one fact per call, not one
121
+ document.** `recall` returns whole entries — store a 180 KB file as a
122
+ single entry and you get it back as a single hit, having gained nothing.
123
+
124
+ ### Teaching the agent how to use it
125
+
126
+ The tools alone don't tell an agent the working rules: search before
127
+ reading files, `recall` → `zeige`, exactly one kind per entry, supersede
128
+ instead of accumulate, retry in the other language. Those live in a skill
129
+ that ships with the repo (not with the PyPI package):
130
+
131
+ ```bash
132
+ cp -r skills/frugal-memory ~/.claude/skills/
133
+ ```
134
+
135
+ Claude Code loads its full text only when the memory comes up; until then
136
+ only the one-line description sits in context.
137
+
138
+ ### Reading another machine's memory
139
+
140
+ Each machine keeps its own memory, and each numbers its entries from 1. A
141
+ session on machine A can read the memory of machine B over SSH — the server
142
+ runs on B, next to its file; the database itself never crosses the network:
143
+
144
+ ```
145
+ claude mcp add memory-b -s project -- \
146
+ ssh b /path/to/frugal-memory/.venv/bin/python \
147
+ /path/to/frugal-memory/memory_server.py --gast
148
+ ```
149
+
150
+ `--gast` (guest) means three things:
151
+
152
+ - **Read-only.** The file is opened with `mode=ro`, and only `recall`,
153
+ `zeige` and `themen` are offered. The writing tools are gone, and so are
154
+ `verdichten` and `pruefe`: upkeep belongs to the owner, who can act on it. A guest's searches do
155
+ not feed the owner's search feedback either, and a guest never migrates
156
+ the schema.
157
+ - **Every id carries the memory's name:** `b#72`, not `#72`. The name is the
158
+ host name in lower case; `MEMORY_NAME` overrides it.
159
+ - **A named id is checked, in both modes.** `zeige("b#72")` asked of any
160
+ memory other than `b` is refused instead of quietly returning that
161
+ memory's own #72. Bare ids (`72`, `#72`) mean the memory being asked.
162
+
163
+ `-s project` keeps the three extra tool definitions out of sessions that do
164
+ not need them. The tools are then called `mcp__memory-b__recall` and so on.
165
+
166
+ ## The Eight Tools
167
+
168
+ | | |
169
+ |---|---|
170
+ | `remember(text, tags, art, ersetzt)` | store an entry; reports similar existing ones and what it would supersede |
171
+ | `recall(query, limit, art, marke, …)` | ranked full-text search, preview by default; under `marke=` it names a better match outside the project |
172
+ | `zeige(ids, voll)` | full text of specific entries, about 6000 characters per call; what doesn't fit is listed with the call that fetches it |
173
+ | `themen(marke, limit, seite, alle)` | browse: which projects exist, or one project's title lines, newest first, a page at a time |
174
+ | `vergessen(ids, grund)` | mark as outdated — never deletes |
175
+ | `einordnen(ids, art)` | assign the knowledge kind of existing entries |
176
+ | `verdichten(marke, art, …)` | find groups of entries that say much the same thing |
177
+ | `pruefe(ids)` | opt-in: have a language model judge contradiction vs. newer state |
178
+
179
+ Full reference with parameters and behavior: [docs/TOOLS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/TOOLS.md).
180
+ With `MEMORY_LANG=en` the same tools come with English names and parameters,
181
+ see [A Note on Language](#a-note-on-language).
182
+
183
+ ## Some Numbers
184
+
185
+ Measured on one real dataset that grew from ~900 to ~1,900 entries along
186
+ the way — evidence from one installation, not a benchmark:
187
+
188
+ - **4.8× cheaper than reading markdown files**, in real tokens, over 275
189
+ real questions (2,359 vs. 11,319 per question). The gap grows with the
190
+ dataset and with file size, because reading a file is all-or-nothing:
191
+ one question against a 188 KB project file costs 94,152 tokens.
192
+ - **82.3 % Recall@10** against the public LoCoMo dataset with a session as
193
+ the unit, **45.1 %** with a single dialogue turn — untuned, first run, at
194
+ 2 ms and 2.7 KB per query.
195
+ - **73 % smaller returns** from the preview, with a calculable worst case.
196
+ - **−23 % expected characters per question** from the feedback loop, at
197
+ 84 % vs. 73 % first-round hit rate, measured over 164 questions from 30
198
+ real sessions in a time-ordered replay — a pair only ever helps *later*
199
+ questions, never itself. 19 questions gained, none lost.
200
+ - **53 % → 64 %** hit rate on 47 real reformulation chains from a one-line
201
+ ranking fix — found by measuring where real search sessions had failed,
202
+ not by guessing. On today's dataset the same fix also *costs* 3 of the 117
203
+ questions that already worked, so the net is +2 of 164.
204
+ - **93 % of the dataset belongs to a project** (1,777 of 1,907 entries),
205
+ and that is how the tool is used. Search itself does not care: general
206
+ knowledge is found as well as project knowledge (92 % vs. 96 %, a tie
207
+ under the 10 % rule). What the project filter buys is precision for
208
+ short questions — 97 % vs. 85 % found at about three words. What it
209
+ costs is everything outside the project: 40 questions about general
210
+ knowledge, asked under 22 project tags, found **0 of 880**. `recall` now
211
+ names the better match outside the tag in 82 % of those cases, and in
212
+ 70 % that line already is the entry sought; on real project questions
213
+ it fires in 7–16 %.
214
+ - **−83 % for a project's title index, −34 % for fetching eight full
215
+ texts**, from capping `themen` and `zeige`. On 110 project questions the
216
+ cap cost not one answer.
217
+
218
+ Where a measurement did not survive a larger sample, it says so:
219
+ [docs/MEASUREMENTS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md), with the raw reports in
220
+ [`messung/`](https://github.com/komakeule57-maker/frugal-memory/tree/main/messung/). The ranking figure above was corrected twice —
221
+ see [The Ranking Fix, Corrected Twice](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md#the-ranking-fix-corrected-twice).
222
+
223
+ ## Documentation
224
+
225
+ | | |
226
+ |---|---|
227
+ | [docs/TOOLS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/TOOLS.md) | all eight tools in detail |
228
+ | [docs/DESIGN.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/DESIGN.md) | the two axes, the morphology, the database schema, and what was left out on purpose |
229
+ | [docs/MEASUREMENTS.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/MEASUREMENTS.md) | what was measured, and the known limitations |
230
+ | [docs/FACTCHECK.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/FACTCHECK.md) | the opt-in fact check: setup, what it can and cannot do |
231
+ | [docs/IMPORT.md](https://github.com/komakeule57-maker/frugal-memory/blob/main/docs/IMPORT.md) | importing an existing folder of notes, and the damage that did |
232
+ | [`messung/`](https://github.com/komakeule57-maker/frugal-memory/tree/main/messung/) | the eight underlying measurement reports (mostly German) |
233
+
234
+ ## A Note on Language
235
+
236
+ German is the default: tool names, status messages and the kind vocabulary
237
+ (`schnittstelle`, `fallstrick`, `entscheidung`, `messwert`, `arbeitsweise`,
238
+ `verlauf`, `gemischt`) are German, and the search stems German and splits
239
+ German compounds.
240
+
241
+ **English mode:** start the server with `MEMORY_LANG=en`. Then
242
+
243
+ - the tools are `remember(text, tags, kind, supersedes)`,
244
+ `recall(query, limit, kind, tag, full, include_superseded)`, `show(ids)`,
245
+ `topics(tag, limit)`, `forget(ids, reason)`, `classify(ids, kind)`,
246
+ `consolidate(tag, kind, threshold, groups)` and `check(ids)`,
247
+ - the kinds are `interface`, `pitfall`, `decision`, `measurement`,
248
+ `workflow`, `history`, `unsorted`,
249
+ - every message is English,
250
+ - the search uses a small English suffix stemmer ("configured" finds
251
+ "configuring") instead of the German one, and does not split compounds.
252
+
253
+ The database itself does not change: kinds are always stored under their
254
+ German names and translated at the border, and German kind names are
255
+ accepted in both modes. What does change is the stem index, so the file
256
+ records the language it was built in and the server refuses to open it
257
+ with the other one. To switch an existing memory, back it up and run
258
+ `MEMORY_LANG=en python3 nachziehen.py` once.
259
+
260
+ Not covered by the switch: the fact-check prompt stays German (it is
261
+ calibrated word for word, and adding one sentence once halved its
262
+ accuracy; only its verdicts are shown in English), and so do the import
263
+ script and the measurement reports. The English stemmer is new and has
264
+ **not** been measured on real questions the way the German search has.
265
+
266
+ ## Files
267
+
268
+ | | |
269
+ |---|---|
270
+ | `memory_server.py` | MCP server, eight tools, search cascade, schema, migrations |
271
+ | `morphologie.py` | stemmer and compound splitter (German; small English stemmer for `MEMORY_LANG=en`) |
272
+ | `werkzeuge_en.py` | the English tool surface for `MEMORY_LANG=en` |
273
+ | `texte_en.py` | English messages, keyed by the German text |
274
+ | `nachziehen.py` | recomputes `stems`/`teile` and refreshes the tag directory |
275
+ | `faktencheck.py` | opt-in second opinion via any OpenAI-compatible model (off unless configured) |
276
+ | `pruefstand_fc.py` | measures the fact check against gold labels from the dataset |
277
+ | `pruefpaare_gebaut.json` | the hand-built and hand-found contradiction pairs |
278
+ | `import_memos.py` | import a file-based memory *(one-off; see docs/IMPORT.md)* |
279
+ | `test_memory.py` | regression net, one case per pitfall (no pytest) |
280
+ | `skills/frugal-memory/SKILL.md` | working rules for the agent, as a Claude Code skill |
281
+ | `requirements.txt` | just `mcp` |
282
+ | `memory.db` | the database — created on first use, never committed |
283
+
284
+ `messung/` keeps the eight measurement **reports**. The scripts that
285
+ produced them and their raw data are not included: they only run against
286
+ the author's own dataset, and the raw data is a verbatim transcript of
287
+ real working sessions.
288
+
289
+ ## License
290
+
291
+ MIT — see [LICENSE](https://github.com/komakeule57-maker/frugal-memory/blob/main/LICENSE).