@cyanmycelium/mcp-persistence 0.0.0-stage → 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/LICENSE +201 -0
- package/README.md +183 -2
- package/contracts/persistence.v1.json +9606 -0
- package/dist/conformance/persistence.conformance.d.ts +4 -0
- package/dist/conformance/persistence.conformance.js +56 -0
- package/dist/conformance/persistence.conformance.js.map +1 -0
- package/dist/contract/errors.d.ts +5 -0
- package/dist/contract/errors.js +9 -0
- package/dist/contract/errors.js.map +1 -0
- package/dist/contract/persistence.protocol.d.ts +83 -0
- package/dist/contract/persistence.protocol.js +75 -0
- package/dist/contract/persistence.protocol.js.map +1 -0
- package/dist/contract/persistence.store.d.ts +29 -0
- package/dist/contract/persistence.store.js +2 -0
- package/dist/contract/persistence.store.js.map +1 -0
- package/dist/contract/persistence.types.d.ts +115 -0
- package/dist/contract/persistence.types.js +2 -0
- package/dist/contract/persistence.types.js.map +1 -0
- package/dist/contract/validation.d.ts +7 -0
- package/dist/contract/validation.js +43 -0
- package/dist/contract/validation.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/artifact.http.d.ts +8 -0
- package/dist/provider/artifact.http.js +69 -0
- package/dist/provider/artifact.http.js.map +1 -0
- package/dist/provider/main.d.ts +2 -0
- package/dist/provider/main.js +82 -0
- package/dist/provider/main.js.map +1 -0
- package/dist/server/declaration.d.ts +18 -0
- package/dist/server/declaration.js +23 -0
- package/dist/server/declaration.js.map +1 -0
- package/dist/server/persistence.behavior.d.ts +16 -0
- package/dist/server/persistence.behavior.js +173 -0
- package/dist/server/persistence.behavior.js.map +1 -0
- package/dist/server/persistence.slot.store.d.ts +45 -0
- package/dist/server/persistence.slot.store.js +94 -0
- package/dist/server/persistence.slot.store.js.map +1 -0
- package/dist/sqlite/sqlite.persistence.store.d.ts +72 -0
- package/dist/sqlite/sqlite.persistence.store.js +561 -0
- package/dist/sqlite/sqlite.persistence.store.js.map +1 -0
- package/docs/assets/logo.png +0 -0
- package/docs/assets/mcp-broker-family.png +0 -0
- package/docs/mcp-contract.md +189 -0
- package/package.json +81 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Guillaume Pelletier (CyanMycelium)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,184 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/assets/logo.png" alt="mcp-persistence: the cyan panda keeping durable data archives" width="180" />
|
|
3
|
+
<img src="docs/assets/mcp-broker-family.png" alt="MCP Broker Family" width="64" height="64" />
|
|
4
|
+
</p>
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# mcp-persistence
|
|
7
|
+
|
|
8
|
+
Durable JSON documents, immutable revisions and streamed binary artifacts for the CyanMycelium MCP family. SQLite keeps revisions, references and idempotency; an internal file directory keeps artifact bytes. The broker decides access.
|
|
9
|
+
|
|
10
|
+
**Status: initial release 0.1.0.** Node.js 22.13 or later is required; its built-in `node:sqlite` API is experimental on Node 22. This is a local single-writer backend, with integration tests, not a distributed storage service.
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
Explorer / Mission Control / MCP client
|
|
14
|
+
|
|
|
15
|
+
mcp-broker
|
|
16
|
+
|
|
|
17
|
+
slot persistence, PersistenceBehavior
|
|
18
|
+
| broker decisions per resource
|
|
19
|
+
IPersistenceStore
|
|
20
|
+
|
|
|
21
|
+
SQLite revisions + internal artifact files
|
|
22
|
+
|
|
23
|
+
Binary upload/download -> loopback HTTP endpoint
|
|
24
|
+
| forwards caller bearer to a fresh broker MCP check
|
|
25
|
+
+-> bounded file stream, never base64 over MCP
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Applications own document schemas, migrations and scene restoration. Persistence stores the states they provide and never restarts their operations.
|
|
29
|
+
|
|
30
|
+
## MCP contract for client development
|
|
31
|
+
|
|
32
|
+
Start with the [wire contract and examples](docs/mcp-contract.md), the [machine-readable JSON schemas](contracts/persistence.v1.json), and the [TypeScript store interface](src/contract/persistence.store.ts). These describe `persistence.v1`, revision 1, independently of SQLite. Import `@cyanmycelium/mcp-persistence/protocol` for backend-independent tool schemas or load `@cyanmycelium/mcp-persistence/contracts/persistence.v1.json`. The behavior publishes the same tool definitions used to generate the manifest. Tests validate live MCP inputs and outputs against these schemas.
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
npm run contracts
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Regenerate the manifest after intentional protocol changes. Client teams can use its descriptors and fixtures while backend work continues.
|
|
39
|
+
|
|
40
|
+
## Develop locally
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install
|
|
44
|
+
npm run build
|
|
45
|
+
npm test
|
|
46
|
+
npm run dev
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For an npm installation, install `@cyanmycelium/mcp-broker` as well to use the optional `--dev` embedded broker. In a checkout it is already a development dependency.
|
|
50
|
+
|
|
51
|
+
`npm run dev` starts its own broker on `127.0.0.1:3000`, the provider and the transfer endpoint on `127.0.0.1:3001`. It explicitly selects `openGuard()`, so no token or policy is needed. The startup banner identifies this mode. Stop any broker already using port 3000, or choose another port with `MCP_PERSISTENCE_BROKER_URL`. Storage defaults to `./data-dev`.
|
|
52
|
+
|
|
53
|
+
On Windows, Node cannot synchronize directory entries. Choose the weaker file-sync durability explicitly before launch:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
$env:MCP_PERSISTENCE_ALLOW_FILE_SYNC_ONLY = '1'
|
|
57
|
+
npm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This setting preserves SQLite transactions and synchronizes artifact file contents, but does not guarantee artifact directory entries against power loss. Without the opt-in, Windows startup is refused. On systems supporting directory fsync, leave the option unset for file-and-directory synchronization. Storage must be a canonical local directory, under operator control, with no symlinks or competing writer.
|
|
61
|
+
|
|
62
|
+
## Move to production
|
|
63
|
+
|
|
64
|
+
Read the broker's [HOWTO: development, policy tests and production](https://github.com/pandaGaume/mcp-broker/blob/main/HOWTO.md). It is supplied with the accompanying broker changes and may need that commit before the GitHub link resolves. It explains `openGuard()`, `auth.dev`, provider identities, OAuth and the access verification matrix.
|
|
65
|
+
|
|
66
|
+
Production uses an independently managed broker. The normal entry point uses `BrokerAccessGuard` and fails startup if its provider credential or accepted declaration is missing. It never falls back to `openGuard()`.
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
$env:MCP_PERSISTENCE_BROKER_URL = 'https://mcp.example.com'
|
|
70
|
+
$env:MCP_PERSISTENCE_RESOURCE_ROOT = '/site1/persistence'
|
|
71
|
+
$env:MCP_PERSISTENCE_DATA = 'C:\ServiceData\mcp-persistence'
|
|
72
|
+
# Inject MCP_PERSISTENCE_PROVIDER_SECRET through the service environment.
|
|
73
|
+
# It must match the provider secretEnv entry in the broker security file.
|
|
74
|
+
npm start
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
On Windows the explicit file-sync opt-in above is also required. Serve the transfer endpoint behind an HTTPS reverse proxy; it always binds loopback. Preserve Authorization and streaming. Every transfer forwards the caller's bearer to the configured broker slot for a new access decision before opening bytes. A known upload id, artifact id or URL grants no permission. A stream already opened is not automatically interrupted by later revocation.
|
|
78
|
+
|
|
79
|
+
Do not carry `--dev` into the service command. `auth.dev` belongs to the broker and keeps the policy active; use normal `npm start` with that broker when testing policy locally. The transfer server has no standalone open-mode CLI switch.
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
| variable | default / meaning |
|
|
84
|
+
|---|---|
|
|
85
|
+
| `MCP_PERSISTENCE_BROKER_URL` | `http://127.0.0.1:3000`, broker origin |
|
|
86
|
+
| `MCP_PERSISTENCE_RESOURCE_ROOT` | `/local/persistence`, must match broker policy |
|
|
87
|
+
| `MCP_PERSISTENCE_PROVIDER_SECRET` | required outside `--dev`, own provider identity |
|
|
88
|
+
| `MCP_PERSISTENCE_DATA` | `./data-dev` in dev, `./data` otherwise |
|
|
89
|
+
| `MCP_PERSISTENCE_TRANSFER_PORT` | `3001`, loopback HTTP listener |
|
|
90
|
+
| `MCP_PERSISTENCE_LOCALE` | `en`, or `fr` for mcp-core grammar |
|
|
91
|
+
| `MCP_PERSISTENCE_ALLOW_FILE_SYNC_ONLY` | `1` explicitly permits weaker Windows file durability |
|
|
92
|
+
|
|
93
|
+
The library's `ISqlitePersistenceOptions` configures size limits and minimum retention. Purge is disabled by infinite retention unless a finite `retentionMs` is explicitly configured in the application assembly. There is no automatic retention job.
|
|
94
|
+
|
|
95
|
+
## Use from TypeScript
|
|
96
|
+
|
|
97
|
+
See [examples/explorer.mjs](examples/explorer.mjs) for a checkpoint saved through a real MCP client. `PersistenceSlotStore` implements the same `IPersistenceStore` as the local `SqlitePersistenceStore`.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
const store = new SqlitePersistenceStore({ directory: '/srv/persistence' });
|
|
101
|
+
const context = { subject: 'trusted-internal-application' };
|
|
102
|
+
const saved = await store.putAsync({
|
|
103
|
+
namespace: 'explorer', id: 'checkpoint-1', kind: 'checkpoint',
|
|
104
|
+
schemaVersion: '1', expectedRevision: 0,
|
|
105
|
+
payload: { sessionId: 'session-1', camera: { position: [0, 0, 10] } },
|
|
106
|
+
references: [], idempotencyKey: crypto.randomUUID()
|
|
107
|
+
}, context);
|
|
108
|
+
await store.closeAsync();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The direct store is an internal trusted API. A remote store ignores `context.subject`; it never sends that value as caller identity. The broker authenticates the connected MCP client. Reuse a mutation's idempotency key after a lost response, along with the identical request.
|
|
112
|
+
|
|
113
|
+
## Tools and resources
|
|
114
|
+
|
|
115
|
+
| tools | broker capability |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `persistence.capabilities` | public protocol and effective limits |
|
|
118
|
+
| `persistence.get`, `list`, `listRevisions` | `persistence.read`, per document; list entries are filtered |
|
|
119
|
+
| `persistence.put` | `persistence.write`; referenced targets additionally require read |
|
|
120
|
+
| `persistence.delete` | `persistence.delete`, logical tombstone |
|
|
121
|
+
| `persistence.beginArtifact` | `persistence.write` on the namespace artifact creation target `_new` |
|
|
122
|
+
| `persistence.uploadAccess`, `commitArtifact`, `abortArtifact` | `persistence.write` on the generated artifact target |
|
|
123
|
+
| `persistence.getArtifact` | `persistence.read` on the artifact |
|
|
124
|
+
| `persistence.purge` | `persistence.admin`, plus retention/reference checks |
|
|
125
|
+
|
|
126
|
+
Each name above has the `persistence.` prefix. Documents and artifacts occupy `<root>/namespaces/<namespace>/documents/<id>` and `<root>/namespaces/<namespace>/artifacts/<id>`. Namespace and id are single validated segments, at most 128 ASCII letters, digits, dots, underscores or hyphens, beginning with a letter, digit or underscore. Business UNS identifiers remain application data.
|
|
127
|
+
|
|
128
|
+
Templates on the provider's own slot:
|
|
129
|
+
|
|
130
|
+
- `persistence://documents/{namespace}/{id}`
|
|
131
|
+
- `persistence://documents/{namespace}/{id}/revisions/{revision}`
|
|
132
|
+
- `persistence://artifacts/{namespace}/{id}`
|
|
133
|
+
|
|
134
|
+
`persistence://capabilities` is public protocol metadata. EN and FR grammars use mcp-core. `_all` exposes opted-in tools and prompts, not resources.
|
|
135
|
+
|
|
136
|
+
## Guarantees and limits
|
|
137
|
+
|
|
138
|
+
- `expectedRevision: 0` creates only. Updates and tombstones must match the current revision. Historical revisions stay immutable until authorized purge.
|
|
139
|
+
- Document writes, reference checks, namespace quota accounting and idempotency results commit in one SQLite transaction, with WAL and synchronous=FULL.
|
|
140
|
+
- Keys are retained at least seven days. Direct stores scope them to subject and namespace. MCP scopes them to namespace because broker caller references are request-scoped. Use UUID keys across applications sharing a namespace. Reuse with different content conflicts; rights are checked before a replay. Actor ownership of an upload follows resource rights, not a claimed user id.
|
|
141
|
+
- Incomplete or wrong-hash uploads never become artifacts. Files are verified, synchronized and renamed before metadata publication. Restart reconciles staged/final files and verifies committed content before serving. Unlink pending after a purge remains quota-accounted until collection.
|
|
142
|
+
- Lists use encrypted authenticated cursors, bound to filters, namespace and the store context, expiring after fifteen minutes. Limits apply before authorization filtering, so a filtered page may be empty with a next cursor. Keep following nextCursor. Lists spanning requests are not snapshots.
|
|
143
|
+
- Default limits: 1 MiB document request, 256 references, 50 entries per page (maximum 200), 10 GiB artifact and 100 GiB logical namespace quota. Four uploads per store subject are active at once, therefore four across the MCP slot. Idempotency has 100,000 entries per namespace. Quota accounting includes retained revisions, reserved upload bytes, artifact metadata, idempotency and pending file deletion; filesystem and SQLite page overhead are additional.
|
|
144
|
+
- Uploads expire after 24 hours. An interrupted stream restarts from byte zero. Completion and abort are replayable. No public bearer download links or file paths are returned.
|
|
145
|
+
|
|
146
|
+
The configured 10 GiB maximum is a limit, not a throughput claim. Tests transfer 512 KiB in bounded chunks. Full hash verification on commit, download and startup is synchronous and can block Node on large archives. Load testing and asynchronous verification are still needed before a high-volume deployment. One process owns one data root; use a single provider instance per root.
|
|
147
|
+
|
|
148
|
+
## Backup and restore
|
|
149
|
+
|
|
150
|
+
Stop the provider cleanly and wait for transfers and SQLite checkpointing to finish. Copy the entire data directory to a protected backup destination, including the database, artifact files and cursor key. Do not copy only a live SQLite main file while omitting its WAL. Do not copy the provider environment or credentials into an application export.
|
|
151
|
+
|
|
152
|
+
Restore into a new canonical data root while the service is stopped. Verify backup file hashes from your backup system, set `MCP_PERSISTENCE_DATA` to that root and start the provider. Startup checks schema compatibility and committed artifact hashes; a missing or corrupt committed file refuses startup. Read a known document and pinned artifact before returning traffic. An offline restore must be exercised with the actual filesystem and backup tool used in production. Application operations are never restarted by restoration.
|
|
153
|
+
|
|
154
|
+
## Layout and tests
|
|
155
|
+
|
|
156
|
+
`src/contract/` holds the shared types; `src/sqlite/` implements documents and files; `src/server/` provides behavior, client and broker declaration; `src/provider/` assembles the executable and byte-transfer endpoint. `/conformance` exports a Vitest suite reusable on direct backends and through the slot.
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
npm run typecheck
|
|
160
|
+
npm run build
|
|
161
|
+
npm test
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Tests cover restart, competing updates, idempotence, quotas, incomplete and corrupt transfers, rename-before-commit recovery, evidence references, pagination, real broker decisions, HTTP transfer authorization and explicit dev versus normal startup.
|
|
165
|
+
|
|
166
|
+
The initial [architecture proposal](docs/brief_persistence_slot.md) records the design. Runtime deviations and current guarantees are specified here, particularly namespace-scoped MCP idempotence and authenticated streaming without reusable tickets.
|
|
167
|
+
|
|
168
|
+
## MCP family
|
|
169
|
+
|
|
170
|
+
| project | responsibility |
|
|
171
|
+
|---|---|
|
|
172
|
+
| [mcp-core](https://github.com/pandaGaume/mcp-core) | behaviors, adapters, schemas, resources and grammars |
|
|
173
|
+
| [mcp-broker](https://github.com/pandaGaume/mcp-broker) | transport, identity, policy decisions and audit |
|
|
174
|
+
| [mcp-uns](https://github.com/pandaGaume/mcp-uns) | UNS conventions and shared access guard |
|
|
175
|
+
| [mcp-vault](https://github.com/pandaGaume/mcp-vault) | sealed secrets and configuration |
|
|
176
|
+
| [mcp-cache](https://github.com/pandaGaume/mcp-cache) | values with a time to live |
|
|
177
|
+
| [mcp-history](https://github.com/pandaGaume/mcp-history) | time series |
|
|
178
|
+
| mcp-persistence | durable documents, pinned revisions and artifacts |
|
|
179
|
+
|
|
180
|
+
The family emblem identifies the ecosystem; it is not a certification.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
Apache-2.0. See [LICENSE](LICENSE).
|