@mnemai/memory-server 0.1.0
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.
- package/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/index.js +1765 -0
- package/package.json +44 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@mnemai/memory-server` are documented here.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-04-01
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Initial published package: MCP Memory 2.0 server (`mnemai-memory` CLI).
|
|
10
|
+
- Evidence-linked graph, hybrid retrieval (substring + token index + optional embeddings), review queue, stdio transport.
|
|
11
|
+
- CI-tested: Vitest (including MCP stdio e2e), integration smoke.
|
|
12
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aditya Shahi
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @mnemai/memory-server
|
|
2
|
+
|
|
3
|
+
**Memory 2.0** — MCP server for an **evidence-linked memory graph**: typed nodes, relationships, freshness decay, contradiction hints, and ranked retrieval with explicit provenance fields. **Local-first** (SQLite file on disk).
|
|
4
|
+
|
|
5
|
+
## Capabilities
|
|
6
|
+
|
|
7
|
+
| Area | What you get |
|
|
8
|
+
|------|----------------|
|
|
9
|
+
| Structure | Typed nodes, edges (`supports`, `contradicts`, …), evidence rows |
|
|
10
|
+
| Retrieval | Hybrid **substring + BM25-style token index** + **optional embeddings**; bounded candidates on large graphs |
|
|
11
|
+
| Trust / time | Freshness decay, refresh, spaced **review queue**, confidence rules with evidence |
|
|
12
|
+
| MCP | Tools + resources (`memory://stats`, `memory://node/{id}`) over **stdio** |
|
|
13
|
+
| Quality gate | **Vitest** (graph, handlers, **real stdio e2e** with official SDK client), **smoke** script |
|
|
14
|
+
|
|
15
|
+
## Install from npm
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx --yes @mnemai/memory-server
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
MCP config (set an absolute DB path):
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"mcpServers": {
|
|
26
|
+
"mnemai-memory": {
|
|
27
|
+
"command": "npx",
|
|
28
|
+
"args": ["--yes", "@mnemai/memory-server"],
|
|
29
|
+
"env": { "TENGU_MEMORY_DB": "/absolute/path/to/memory.db" }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Publishing and version bumps: see repo [RELEASING.md](../../RELEASING.md). `prepublishOnly` runs **`pnpm run verify:ship`**.
|
|
36
|
+
|
|
37
|
+
## What `verify:ship` checks
|
|
38
|
+
|
|
39
|
+
1. Build `dist/index.js` (CLI **`mnemai-memory`**, shebang for Unix).
|
|
40
|
+
2. Typecheck.
|
|
41
|
+
3. **Vitest** — graph, retrieval, embeddings (mocked HTTP), **MCP stdio e2e** (`ping`, tools, resources, stderr clean on success).
|
|
42
|
+
4. In-process **smoke** script.
|
|
43
|
+
|
|
44
|
+
**Scope:** Proves the **reference SDK wire path** on CI’s OS (Linux). Hosts can still differ (timeouts, stderr). Not a guarantee for every proprietary MCP client.
|
|
45
|
+
|
|
46
|
+
Repo CI also builds the workspace, typechecks, verifies **mission** + **verification** servers, **npm pack** sanity, and the **platform demo** (see root [README.md](../../README.md)).
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
- Node.js **>= 18**
|
|
51
|
+
|
|
52
|
+
## From this monorepo
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# repo root — print MCP JSON with absolute paths
|
|
56
|
+
pnpm run memory:onboard
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
node packages/memory-server/dist/index.js
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Environment variables
|
|
64
|
+
|
|
65
|
+
| Variable | Purpose |
|
|
66
|
+
|----------|---------|
|
|
67
|
+
| `TENGU_MEMORY_DB` | Path to the SQLite file (default: `~/.tengu/memory.db`) |
|
|
68
|
+
| `TENGU_MEMORY_SYNC_WRITES=1` | Flush to disk immediately after writes (stronger durability, slower) |
|
|
69
|
+
| `TENGU_MEMORY_MATCH_LEXICAL` | Weight for substring overlap in hybrid `matchScore` (default `0.35`; renormalized with index/semantic) |
|
|
70
|
+
| `TENGU_MEMORY_MATCH_INDEX` | Weight for BM25-style token index (default `0.45`) |
|
|
71
|
+
| `TENGU_MEMORY_MATCH_SEMANTIC` | Weight for embedding cosine channel when enabled (default `0.2`) |
|
|
72
|
+
| `TENGU_MEMORY_EMBED_URL` | OpenAI-compatible **POST** embeddings endpoint |
|
|
73
|
+
| `TENGU_MEMORY_EMBED_KEY` | Bearer token for that endpoint |
|
|
74
|
+
| `TENGU_MEMORY_EMBED_MODEL` | Embedding model id (default `text-embedding-3-small`) |
|
|
75
|
+
| `TENGU_MEMORY_QUERY_FULL_SCAN_MAX_NODES` | Graphs larger than this use **index-bounded candidates** + recent seed (default `1600`; `0` = always use smart path when the index matches) |
|
|
76
|
+
| `TENGU_MEMORY_QUERY_INDEX_CANDIDATE_CAP` | Floor for max BM25-hit ids per query; effective cap is `max(this, limit×25)` (default `600`) |
|
|
77
|
+
| `TENGU_MEMORY_QUERY_RECENT_SEED` | Union this many most recently updated nodes (after filters) (default `200`) |
|
|
78
|
+
|
|
79
|
+
## MCP config (clone / local `node`)
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcpServers": {
|
|
84
|
+
"mnemai-memory": {
|
|
85
|
+
"command": "node",
|
|
86
|
+
"args": ["/absolute/path/to/repo/packages/memory-server/dist/index.js"],
|
|
87
|
+
"env": { "TENGU_MEMORY_DB": "/absolute/path/to/my-memory.db" }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Use **absolute paths** — hosts often use a cwd that is not your repo.
|
|
94
|
+
|
|
95
|
+
## Tools
|
|
96
|
+
|
|
97
|
+
| Tool | Role |
|
|
98
|
+
|------|------|
|
|
99
|
+
| `memory.create_node` | Create a typed node; returns `{ node, trustPolicy }`; optional `reviewIntervalDays` |
|
|
100
|
+
| `memory.query` | Hybrid ranked search; optional `useLexicalIndex`, `useSemantic`, `fullScan` |
|
|
101
|
+
| `memory.add_edge` | Graph edge (`contradicts`, `supports`, …) |
|
|
102
|
+
| `memory.attach_evidence` | Append evidence to a node |
|
|
103
|
+
| `memory.refresh` | Reaffirm / boost freshness; optional `reaffirmationNote` |
|
|
104
|
+
| `memory.list_review_queue` | Spaced verification queue |
|
|
105
|
+
| `memory.verify_node` | Confirm a memory still holds |
|
|
106
|
+
| `memory.embed_node` | Store embedding (requires `TENGU_MEMORY_EMBED_*`) |
|
|
107
|
+
| `memory.stats` | Aggregate stats (+ index / embedding counts) |
|
|
108
|
+
|
|
109
|
+
## Resources
|
|
110
|
+
|
|
111
|
+
| URI | Role |
|
|
112
|
+
|-----|------|
|
|
113
|
+
| `memory://stats` | Same JSON as `memory.stats` |
|
|
114
|
+
| `memory://node/{nodeId}` | Node + edges |
|
|
115
|
+
|
|
116
|
+
## Security, performance, limits
|
|
117
|
+
|
|
118
|
+
- [Security & privacy](../../docs/Memory-2.0-Security-Privacy.md)
|
|
119
|
+
- [Performance (test SLOs)](../../docs/Memory-2.0-Performance.md)
|
|
120
|
+
- [Host matrix](../../docs/Memory-2.0-Host-Matrix.md)
|
|
121
|
+
|
|
122
|
+
**Limits (honest):** **sql.js** build has **no FTS5**; lexical search uses **`node_search_tokens`** + BM25-style scoring plus substring match. **Embeddings** are optional and require your own API. Large graphs use **bounded retrieval** (see env vars above). These tradeoffs favor **portable, predictable** local operation over mimicking a hosted search product.
|
|
123
|
+
|
|
124
|
+
## Related docs
|
|
125
|
+
|
|
126
|
+
- [RFC: Memory 2.0](../../docs/RFC-Memory-2.0.md)
|
|
127
|
+
- [Runtime compatibility](../../docs/Memory-2.0-Runtime-Compatibility.md)
|
|
128
|
+
- [Competitive benchmark](../../docs/Memory-2.0-Competitive-Benchmark.md)
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|