@safekb/mcp 0.0.0-stage → 0.2.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 ADDED
@@ -0,0 +1,44 @@
1
+ SafeKB MCP Client License
2
+
3
+ Copyright (c) 2026 Mustafa Öztürk (the "Licensor"). All rights reserved.
4
+
5
+ 1. Grant. Subject to this license, the Licensor grants you a non-exclusive,
6
+ non-transferable, revocable right to install and run unmodified copies of
7
+ this software for the sole purpose of connecting to a SafeKB service that
8
+ you are authorized to use, including a SafeKB instance operated for you
9
+ under a separate written agreement with the Licensor.
10
+
11
+ 2. Restrictions. Except where applicable law does not allow this restriction,
12
+ you may not:
13
+ (a) modify the software or create derivative works of it;
14
+ (b) redistribute, sublicense, sell, rent or lease the software, or offer it
15
+ as part of another product or service;
16
+ (c) use the software, or any part of it, to build or operate a product or
17
+ service that competes with SafeKB;
18
+ (d) remove or alter any copyright, license or attribution notice.
19
+
20
+ 3. Ownership. The software is licensed, not sold. The Licensor keeps all
21
+ rights in it that this license does not expressly grant.
22
+
23
+ 4. Your keys and data. The software keeps secrets and keys on your device.
24
+ You alone are responsible for backing them up. The Licensor cannot recover
25
+ content that was sealed with a secret you no longer hold.
26
+
27
+ 5. Third-party components. The software includes open-source components that
28
+ stay under their own licenses, listed in THIRD-PARTY-NOTICES.md. Nothing in
29
+ this license limits your rights under those licenses.
30
+
31
+ 6. Termination. This license ends automatically if you breach it. When it
32
+ ends you must stop using the software and delete your copies.
33
+
34
+ 7. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
35
+ KIND, EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY,
36
+ FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
37
+
38
+ 8. Limitation of liability. TO THE EXTENT THE LAW ALLOWS, THE LICENSOR IS NOT
39
+ LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES, OR FOR ANY
40
+ LOSS OF DATA, KEYS, PROFITS OR BUSINESS, ARISING FROM THE SOFTWARE OR ITS
41
+ USE. A separate written agreement between you and the Licensor, where one
42
+ exists, takes precedence over sections 7 and 8.
43
+
44
+ Other uses need a commercial license from the Licensor: https://safekb.com
package/README.md CHANGED
@@ -1,3 +1,167 @@
1
- # Temporary Holding Version
1
+ # @safekb/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local MCP client for SafeKB (stdio). It proxies the hosted SafeKB tools and adds **sealed** documents
4
+ and folders: content is encrypted on your machine, and the server stores only ciphertext.
5
+
6
+ Needs Node 20 or newer.
7
+
8
+ ## Setup
9
+
10
+ ```sh
11
+ npx -y @safekb/mcp --authorize --url <your SafeKB API URL>
12
+ ```
13
+
14
+ This opens the browser and prints a **pairing code**. Sign in on the page, choose the spaces, type the
15
+ pairing code, and the client saves a service-account token to `~/.config/safekb/mcp.json` (mode 0600).
16
+ It then prints the account it was authorized as; check that it is yours. There is no default URL.
17
+
18
+ Last, it chooses where this machine keeps the keys of new seal roots (see [Where secrets are kept](#where-secrets-are-kept)).
19
+ With a system keyring that is the choice. Without one, as on most servers, it warns and asks before it
20
+ uses key files. `npx -y @safekb/mcp --configure` makes the same choice again without re-authorizing.
21
+ A client authorized before this choice existed makes it by itself on its next start when the system
22
+ keyring works; only key files need `--configure`, because they need your agreement.
23
+
24
+ How the token gets to the client: the page never sees it. The page hands the client a single-use code
25
+ (valid for two minutes), and the client redeems that code itself, proving with a secret it never wrote
26
+ anywhere that it is the process that started the flow. The URL in the browser launcher's arguments is
27
+ readable by other users of the machine, so it holds nothing that completes the flow; the pairing code
28
+ is what ties your sign-in to your terminal. Every authorization creates its own token: authorizing
29
+ again never changes the token or the spaces of another client. Revoke one under Settings → service
30
+ accounts.
31
+
32
+ Claude Code:
33
+
34
+ ```sh
35
+ claude mcp add safekb -- npx -y @safekb/mcp
36
+ ```
37
+
38
+ Claude Desktop and Cursor (`mcpServers` in their MCP config file):
39
+
40
+ ```json
41
+ { "mcpServers": { "safekb": { "command": "npx", "args": ["-y", "@safekb/mcp"] } } }
42
+ ```
43
+
44
+ ## Options
45
+
46
+ | Flag | Environment | Meaning |
47
+ | --- | --- | --- |
48
+ | `--url <api url>` | `KB_API_URL` | API base URL. Otherwise the URL saved by `--authorize`. When serving, it must have the origin the token was issued for: the token is never sent anywhere else. |
49
+ | `--config <path>` | `SAFEKB_MCP_CONFIG` | Token file. Default `~/.config/safekb/mcp.json`. Use one per project for per-project access. |
50
+ | `--keyring <dir>` | `SAFEKB_SEALED_KEYRING` | Directory of sealed key files (`*.json`). Otherwise the one `--configure` chose, if any. |
51
+ | `--sealed-only` | | Expose only the sealed tools; the hosted tools are not proxied. |
52
+ | `--authorize` | | Authorize in the browser and write the token file, then choose the key store. |
53
+ | `--configure` | | Choose where new sealed keys are kept. Writes `stores.json` next to the token file. |
54
+ | `--sidecar` | | Run the sidecar in this terminal. With `--confirm` it asks before every release of a secret. |
55
+ | `--sidecar-socket <path>` | `SAFEKB_SIDECAR_SOCKET` | The sidecar's socket. Default `sidecar.sock` next to the token file. |
56
+ | | `SAFEKB_SEALED_IDLE_TTL` | Seconds an unlocked seal root may stay idle. Default 900. `unlock_sealed` can set it per root with `idle_ttl_seconds` (60 to 3600). |
57
+ | | `SAFEKB_HOSTED_TIMEOUT` | Seconds a hosted tool call may take. Default 300. |
58
+
59
+ The client refuses to start when the token file or a keyring file is readable by group or others,
60
+ when `--url` names another origin than the token's, when the hosted endpoint cannot be reached, or
61
+ when a hosted tool has the name of a sealed tool.
62
+
63
+ A hosted tool call that gets no answer (timeout, connection lost) is reported as *sent but not
64
+ confirmed*: it may have run, and it is not sent again. Check the state before repeating it.
65
+
66
+ ## Sealed documents
67
+
68
+ A **seal root** is a sealed folder (one secret opens everything in it) or a standalone sealed document.
69
+ Its secret is a generated key or a passphrase.
70
+
71
+ - `create_sealed_folder` / `insert_sealed_document` with `store` or `key_out_path` make a new seal root
72
+ and keep its secret on this machine. The secret is never returned to the model.
73
+ **Back it up: a lost secret cannot be recovered.**
74
+ - `unlock_sealed` with only `root_id` takes the secret from the store that has it; `secret_file` reads
75
+ it from a file.
76
+ - Then `search_sealed`, `list_sealed`, `read_sealed_document`, `get_sealed_section`,
77
+ `update_sealed_document`, `replace_in_sealed_document`, and the move, archive, delete, export,
78
+ attachment and deposit tools.
79
+ - `lock_sealed`, the idle timeout, or the end of the process forget the keys.
80
+
81
+ ## Where secrets are kept
82
+
83
+ Every seal root has its own secret, and each can be kept in a different place. All three work side by
84
+ side: `unlock_sealed` with only `root_id` asks each store and uses the one that has the secret. If two
85
+ have it, it stops and asks for `store`.
86
+
87
+ | `store` | What is kept | Where | At rest |
88
+ | --- | --- | --- | --- |
89
+ | `system` | a generated key | the operating system's keyring: Keychain (macOS), Credential Manager (Windows), Secret Service (Linux) | encrypted by the system |
90
+ | `file` | a generated key | a file (mode 0600) in the keyring directory | not encrypted |
91
+ | `sidecar` | a passphrase you type | the memory of a separate process, for a time you choose | nowhere |
92
+ | `default` | | whichever of `system` and `file` `--configure` chose | |
93
+
94
+ `key_out_path` still writes a key file to a path of your choice, and `passphrase` still takes one as
95
+ text (which then is in the conversation transcript).
96
+
97
+ The system keyring is used only where `--configure` found it working. On Linux that means a running
98
+ Secret Service (GNOME Keyring, KWallet, KeePassXC); the kernel keyring is never used, because it
99
+ forgets its content at logout. Keys are kept there with [`@napi-rs/keyring`](https://github.com/Brooooooklyn/keyring-node).
100
+
101
+ ### The sidecar
102
+
103
+ The sidecar keeps passphrases out of files, out of the keyring and out of the conversation. Run it in
104
+ a terminal of its own:
105
+
106
+ ```sh
107
+ npx -y @safekb/mcp --sidecar
108
+ ```
109
+
110
+ - `add <root id> [minutes]` asks for the root's secret without showing it and holds it for that long
111
+ (default 15 minutes). The time is fixed when you type the secret: use does not extend it.
112
+ - `list`, `drop <root id>`, `drop all`, `quit`.
113
+ - A new seal root with `store: "sidecar"` makes the sidecar ask you for a new passphrase, twice, while
114
+ the tool call waits.
115
+ - With `--confirm` it asks for your approval before every release of a secret.
116
+
117
+ Several roots can be held at once, each with its own passphrase and time. The sidecar listens on a Unix
118
+ socket only your user can open; it is not available on Windows. Any program running as you can still
119
+ ask it for a held secret, which is what `--confirm` is for.
120
+
121
+ ## Sealed credentials
122
+
123
+ A sealed credential belongs to a seal root. Its password, TOTP seed, `sealed_notes` and the values of
124
+ sealed custom fields are encrypted on your machine; its title, username, url, tags, `notes`, visible
125
+ custom fields and the key name of every custom field (sealed ones too) stay readable by the server, so the standard `search_credentials`, `list_credentials` and
126
+ `find_credential_duplicates` keep working. Never put a secret into `notes`.
127
+
128
+ - `insert_sealed_credential`, `update_sealed_credential`, `delete_sealed_credential`: signed by the unlocked root.
129
+ - `move_sealed_credential` hands a credential to another seal root; both roots must be unlocked.
130
+ - `reveal_sealed_credential` and `get_sealed_totp` decrypt locally. The hosted `reveal_credential` and
131
+ `get_credential_totp` cannot open a sealed credential.
132
+ - Visible fields can be edited without the secret. Such an edit is flagged (`visible_tampered`) with the
133
+ changed fields until a signed save accepts it (`accept_visible_changes`).
134
+
135
+ ### Migrating server-encrypted credentials
136
+
137
+ `migrate_credentials_to_sealed` turns every credential the token can see into a sealed one. It is
138
+ irreversible per credential: the server drops its own encrypted secrets and that credential's history.
139
+
140
+ 1. Unlock the target root, then run it with `dry_run: true` (the default). Nothing changes. It lists the
141
+ credentials, says which have notes, and flags notes that match a few secret patterns. That scan is
142
+ advisory and misses secrets.
143
+ 2. Decide every note, because today notes are encrypted and afterwards they are either sealed or
144
+ readable by the server and searchable. Run with `dry_run: false` and
145
+ - `unflagged_notes: "sealed"` or `"visible"` for notes without a flag (no default), and
146
+ - each flagged credential in `sealed_notes_ids` or `visible_notes_ids`.
147
+ 3. Before a credential is sent, its ciphertext is opened with the root key and compared with the dry
148
+ run. After the run the report counts `sealed_and_verified`, `sealed_but_unverified` and
149
+ `not_migrated`. Only when the last two are zero is the migration finished.
150
+ 4. A run can be repeated: sealed credentials are re-verified, not rewritten, and history left behind by
151
+ an interrupted run is purged. A credential that changed since the dry run needs a new dry run.
152
+
153
+ Old database and storage backups keep the server-encrypted copies until they age out.
154
+
155
+ ## What sealing does not protect
156
+
157
+ - Whatever a tool returns enters the local conversation transcript and is sent to the model provider.
158
+ The same holds for a secret passed as text; use a store or `secret_file`.
159
+ - A program running as your user can read a key file, ask the system keyring or the sidecar for a
160
+ secret, and read the memory of this client while a root is unlocked.
161
+ - A session that has unlocked a root can be tricked by content it reads into copying it elsewhere.
162
+ - A compromised local machine, or a malicious server serving stale data.
163
+ - Metadata: existence, sizes, timestamps, tree position.
164
+
165
+ ## License
166
+
167
+ Proprietary: free to install and run for connecting to a SafeKB service you are authorized to use. See [LICENSE](LICENSE); bundled open-source components are listed in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
@@ -0,0 +1,121 @@
1
+ # Third-party notices
2
+
3
+ The distributed file `dist/safekb-mcp.js` bundles the components below. Each stays under its own license.
4
+
5
+ ## @noble/curves
6
+
7
+ ```
8
+ The MIT License (MIT)
9
+
10
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the “Software”), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in
20
+ all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
+ THE SOFTWARE.```
29
+
30
+ ## @noble/ed25519
31
+
32
+ ```
33
+ The MIT License (MIT)
34
+
35
+ Copyright (c) 2019 Paul Miller (https://paulmillr.com)
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining a copy
38
+ of this software and associated documentation files (the “Software”), to deal
39
+ in the Software without restriction, including without limitation the rights
40
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
41
+ copies of the Software, and to permit persons to whom the Software is
42
+ furnished to do so, subject to the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be included in
45
+ all copies or substantial portions of the Software.
46
+
47
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
50
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
51
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
53
+ THE SOFTWARE.```
54
+
55
+ ## @noble/hashes
56
+
57
+ ```
58
+ The MIT License (MIT)
59
+
60
+ Copyright (c) 2022 Paul Miller (https://paulmillr.com)
61
+
62
+ Permission is hereby granted, free of charge, to any person obtaining a copy
63
+ of this software and associated documentation files (the “Software”), to deal
64
+ in the Software without restriction, including without limitation the rights
65
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
+ copies of the Software, and to permit persons to whom the Software is
67
+ furnished to do so, subject to the following conditions:
68
+
69
+ The above copyright notice and this permission notice shall be included in
70
+ all copies or substantial portions of the Software.
71
+
72
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78
+ THE SOFTWARE.```
79
+
80
+ ## hash-wasm
81
+
82
+ ```
83
+ MIT License
84
+
85
+ Copyright (c) 2020 Dani Biró
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining a copy
88
+ of this software and associated documentation files (the "Software"), to deal
89
+ in the Software without restriction, including without limitation the rights
90
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
91
+ copies of the Software, and to permit persons to whom the Software is
92
+ furnished to do so, subject to the following conditions:
93
+
94
+ The above copyright notice and this permission notice shall be included in all
95
+ copies or substantial portions of the Software.
96
+
97
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
98
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
99
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
100
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
101
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
102
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
103
+ SOFTWARE.
104
+
105
+ Embedded C implementations might use other, similarly permissive licenses.
106
+ Check the beginning of the files from the /src directory.
107
+
108
+ Special thank you to the authors of original C algorithms:
109
+ - Alexander Peslyak <solar@openwall.com>
110
+ - Aleksey Kravchenko <rhash.admin@gmail.com>
111
+ - Colin Percival
112
+ - Stephan Brumme <create@stephan-brumme.com>
113
+ - Steve Reid <steve@edmweb.com>
114
+ - Samuel Neves <sneves@dei.uc.pt>
115
+ - Solar Designer <solar@openwall.com>
116
+ - Project Nayuki
117
+ - ARM Limited
118
+ - Yanbo Li dreamfly281@gmail.com, goldboar@163.comYanbo Li
119
+ - Mark Adler
120
+ - Yann Collet
121
+ ```