|
| 1 | +# @rozek/sds-mcp-server-jj |
| 2 | + |
| 3 | +MCP (Model Context Protocol) server for the **shareable-data-store** (SDS) family — backed by the [json-joy](https://github.com/streamich/json-joy) CRDT engine. Exposes all SDS store and entry operations as MCP tools so that AI agents can manage CRDT stores, entries, items, links, tokens, and batch workflows through the standard MCP tool-calling interface. |
| 4 | + |
| 5 | +This package is the **runnable binary**. The tool definitions, handlers, and shared infrastructure live in [`@rozek/sds-mcp-server`](../sds-mcp-server/README.md); this package wires in the json-joy store factory and exposes the result as the `sds-mcp-server-jj` executable. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +| requirement | details | |
| 12 | +| --- | --- | |
| 13 | +| **Node.js 22.5+** | required to run the server. Download from [nodejs.org](https://nodejs.org). | |
| 14 | +| **MCP client** | any host that speaks the Model Context Protocol (Claude Desktop, custom agent, etc.) | |
| 15 | +| **SDS server** | only required for network operations (`sds_store_sync`, `sds_store_ping`, `sds_token_issue`). All local read/write tools work entirely offline against the SQLite file. | |
| 16 | +| **JWT tokens** | server operations need a client token (scope `read` or `write`) or an admin token (scope `admin`). Tokens are issued by the server's `POST /api/token` endpoint via `sds_token_issue`. | |
| 17 | + |
| 18 | +SQLite support is built directly into Node.js since version 22.5 via the `node:sqlite` module — no separate database driver, no native C++ addon, and no build toolchain is needed. The server binary therefore runs with **Node.js as its only dependency**. |
| 19 | + |
| 20 | +> **Note on stability:** `node:sqlite` is classified as *Stability 1 — Experimental* in the Node.js 22 and 24 documentation. In practice the API has been stable since its introduction. The server suppresses the associated runtime warning automatically. |
| 21 | +
|
| 22 | +--- |
| 23 | + |
| 24 | +## Installation |
| 25 | + |
| 26 | +```bash |
| 27 | +npm add @rozek/sds-mcp-server-jj |
| 28 | +``` |
| 29 | + |
| 30 | +After installation the `sds-mcp-server-jj` command is available in the project's `node_modules/.bin/` directory. |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## Running without Installation |
| 35 | + |
| 36 | +The package includes a `bin` entry, so it can be started directly via `npx` — no prior installation required: |
| 37 | + |
| 38 | +```bash |
| 39 | +npx @rozek/sds-mcp-server-jj |
| 40 | +``` |
| 41 | + |
| 42 | +This is the recommended way to configure MCP hosts that manage servers themselves. Register the server in your MCP host configuration using `npx` as the command: |
| 43 | + |
| 44 | +**Claude Desktop (`claude_desktop_config.json`):** |
| 45 | + |
| 46 | +```json |
| 47 | +{ |
| 48 | + "mcpServers": { |
| 49 | + "sds": { |
| 50 | + "command": "npx", |
| 51 | + "args": [ "-y", "@rozek/sds-mcp-server-jj" ] |
| 52 | + } |
| 53 | + } |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +The `-y` flag skips the confirmation prompt when `npx` downloads the package. Remove it if you prefer to confirm each download. |
| 58 | + |
| 59 | +> **Note on Node.js version:** `npx` uses whatever `node` is on your `PATH`. Make sure it is version 22.5 or later before adding the server to a host configuration. |
| 60 | +
|
| 61 | +--- |
| 62 | + |
| 63 | +## Configuration (installed package) |
| 64 | + |
| 65 | +If you have installed `@rozek/sds-mcp-server-jj` locally or globally, register the built binary directly in your MCP host configuration: |
| 66 | + |
| 67 | +**Claude Desktop (`claude_desktop_config.json`):** |
| 68 | + |
| 69 | +```json |
| 70 | +{ |
| 71 | + "mcpServers": { |
| 72 | + "sds": { |
| 73 | + "command": "node", |
| 74 | + "args": [ "/path/to/node_modules/@rozek/sds-mcp-server-jj/dist/sds-mcp-server-jj.js" ] |
| 75 | + } |
| 76 | + } |
| 77 | +} |
| 78 | +``` |
| 79 | + |
| 80 | +The server communicates over **stdio** — no port, no HTTP server, no daemon is required. |
| 81 | + |
| 82 | +### Server-level defaults |
| 83 | + |
| 84 | +You can pre-configure default values for `StoreId`, `PersistenceDir`, `ServerURL`, `Token`, and `AdminToken` so that individual tool calls do not need to repeat them. There are two ways to do this — they can be combined freely, and **tool parameters always take precedence** over both. |
| 85 | + |
| 86 | +**CLI arguments** (passed in the `args` array of the MCP host config): |
| 87 | + |
| 88 | +| argument | applies to | |
| 89 | +| --- | --- | |
| 90 | +| `--store <id>` | default `StoreId` for all tools | |
| 91 | +| `--persistence-dir <path>` | default `PersistenceDir` for all tools | |
| 92 | +| `--server <url>` | default `ServerURL` for sync/token tools | |
| 93 | +| `--token <jwt>` | default client `Token` for sync tools | |
| 94 | +| `--admin-token <jwt>` | default `AdminToken` for `sds_token_issue` | |
| 95 | + |
| 96 | +**Environment variables** (set in the `env` block of the MCP host config, or in the shell): |
| 97 | + |
| 98 | +| variable | applies to | |
| 99 | +| --- | --- | |
| 100 | +| `SDS_STORE_ID` | default `StoreId` for all tools | |
| 101 | +| `SDS_PERSISTENCE_DIR` | default `PersistenceDir` for all tools | |
| 102 | +| `SDS_SERVER_URL` | default `ServerURL` for sync/token tools | |
| 103 | +| `SDS_TOKEN` | default client `Token` for sync tools | |
| 104 | +| `SDS_ADMIN_TOKEN` | default `AdminToken` for `sds_token_issue` | |
| 105 | + |
| 106 | +**Precedence** (highest to lowest): tool parameter → CLI argument → environment variable → built-in default (`~/.sds` for `PersistenceDir`). |
| 107 | + |
| 108 | +**Example — fixed store and data directory via CLI args:** |
| 109 | + |
| 110 | +```json |
| 111 | +{ |
| 112 | + "mcpServers": { |
| 113 | + "sds": { |
| 114 | + "command": "node", |
| 115 | + "args": [ |
| 116 | + "/path/to/node_modules/@rozek/sds-mcp-server-jj/dist/sds-mcp-server-jj.js", |
| 117 | + "--store", "my-notes", |
| 118 | + "--persistence-dir", "/home/alice/.my-sds-data" |
| 119 | + ] |
| 120 | + } |
| 121 | + } |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +**Example — sync server and token via environment variables:** |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "mcpServers": { |
| 130 | + "sds": { |
| 131 | + "command": "node", |
| 132 | + "args": [ "/path/to/.../sds-mcp-server-jj.js" ], |
| 133 | + "env": { |
| 134 | + "SDS_SERVER_URL": "wss://sync.example.com", |
| 135 | + "SDS_TOKEN": "eyJhbGci..." |
| 136 | + } |
| 137 | + } |
| 138 | + } |
| 139 | +} |
| 140 | +``` |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +## Tool reference |
| 145 | + |
| 146 | +This package exposes 20 tools grouped into six categories. Full documentation for every tool — parameters, return values, error conditions, and examples — is in the [`@rozek/sds-mcp-server` README](../sds-mcp-server/README.md#tool-reference). |
| 147 | + |
| 148 | +| category | tools | |
| 149 | +| --- | --- | |
| 150 | +| **store** | `sds_store_info`, `sds_store_ping`, `sds_store_sync`, `sds_store_destroy`, `sds_store_export`, `sds_store_import` | |
| 151 | +| **entry** | `sds_entry_create`, `sds_entry_get`, `sds_entry_list`, `sds_entry_update`, `sds_entry_move`, `sds_entry_delete`, `sds_entry_restore`, `sds_entry_purge` | |
| 152 | +| **trash** | `sds_trash_list`, `sds_trash_purge_all`, `sds_trash_purge_expired` | |
| 153 | +| **tree** | `sds_tree_show` | |
| 154 | +| **token** | `sds_token_issue` | |
| 155 | +| **batch** | `sds_batch` | |
| 156 | + |
| 157 | +--- |
| 158 | + |
| 159 | +## Examples |
| 160 | + |
| 161 | +### Local store — first steps |
| 162 | + |
| 163 | +``` |
| 164 | +sds_entry_create { StoreId: "notes", Label: "Recipes", MIMEType: "text/plain", Value: "Pasta: boil, sauce, enjoy" } |
| 165 | +sds_tree_show { StoreId: "notes" } |
| 166 | +sds_entry_list { StoreId: "notes", Id: "root", Fields: ["Label", "MIMEType"] } |
| 167 | +sds_entry_get { StoreId: "notes", Id: "<uuid>" } |
| 168 | +``` |
| 169 | + |
| 170 | +### Batch setup |
| 171 | + |
| 172 | +Initialise a folder structure in one round trip: |
| 173 | + |
| 174 | +``` |
| 175 | +sds_batch { |
| 176 | + StoreId: "team-wiki", |
| 177 | + Commands: [ |
| 178 | + { Tool: "sds_entry_create", Params: { Label: "Documentation", MIMEType: "text/plain" } }, |
| 179 | + { Tool: "sds_entry_create", Params: { Label: "Meeting Notes", MIMEType: "text/plain" } }, |
| 180 | + { Tool: "sds_entry_create", Params: { Label: "Decisions", MIMEType: "text/plain" } } |
| 181 | + ] |
| 182 | +} |
| 183 | +``` |
| 184 | + |
| 185 | +### Export and restore |
| 186 | + |
| 187 | +``` |
| 188 | +sds_store_export { StoreId: "notes", Encoding: "json", OutputFile: "/backups/notes.json" } |
| 189 | +sds_store_import { StoreId: "notes-restored", InputFile: "/backups/notes.json", InputEncoding: "json" } |
| 190 | +``` |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +## License |
| 195 | + |
| 196 | +[MIT License](../../LICENSE.md) © Andreas Rozek |
0 commit comments