datanotes 2.0.0 → 3.0.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/NOTICE +9 -0
- package/README.md +207 -28
- package/SECURITY.md +92 -45
- package/dist/THIRD-PARTY-NOTICES.txt +682 -0
- package/dist/api/catalog.d.cts +69 -0
- package/dist/api/catalog.d.ts +50 -2
- package/dist/api/cli-options.d.cts +39 -0
- package/dist/api/cli-options.d.ts +39 -0
- package/dist/api/client.d.cts +89 -0
- package/dist/api/client.d.ts +19 -30
- package/dist/api/docs.d.cts +211 -0
- package/dist/api/docs.d.ts +211 -0
- package/dist/api/guidance.d.cts +81 -0
- package/dist/api/guidance.d.ts +81 -0
- package/dist/api/index.cjs +6610 -2247
- package/dist/api/index.d.cts +13 -0
- package/dist/api/index.d.ts +10 -7
- package/dist/api/index.js +6610 -2247
- package/dist/api/local.cjs +118 -6
- package/dist/api/local.d.cts +95 -0
- package/dist/api/local.d.ts +70 -6
- package/dist/api/local.js +104 -6
- package/dist/api/mcp.cjs +17384 -0
- package/dist/api/mcp.d.cts +108 -0
- package/dist/api/mcp.d.ts +108 -0
- package/dist/api/mcp.js +17334 -0
- package/dist/api/otlp.d.cts +65 -0
- package/dist/api/redact.d.cts +17 -0
- package/dist/api/redact.d.ts +17 -0
- package/dist/api/requests.d.cts +26 -0
- package/dist/api/requests.d.ts +14 -16
- package/dist/api/results.d.cts +16 -0
- package/dist/api/results.d.ts +2 -1
- package/dist/api/tokens.d.cts +7 -0
- package/dist/datanotes.cjs +62911 -28409
- package/dist/docs/administration/configuration.md +59 -0
- package/dist/docs/administration/docker.md +80 -0
- package/dist/docs/administration/git-sync.md +71 -0
- package/dist/docs/administration/limits.md +69 -0
- package/dist/docs/administration/run-the-service.md +219 -0
- package/dist/docs/administration/status.md +61 -0
- package/dist/docs/administration/use-with-obsidian.md +75 -0
- package/dist/docs/api/operations/add_column.md +49 -0
- package/dist/docs/api/operations/add_constraint.md +55 -0
- package/dist/docs/api/operations/adopt_rows.md +50 -0
- package/dist/docs/api/operations/align_relations.md +41 -0
- package/dist/docs/api/operations/alter_column.md +46 -0
- package/dist/docs/api/operations/alter_table.md +67 -0
- package/dist/docs/api/operations/batch.md +48 -0
- package/dist/docs/api/operations/changes_stream.md +28 -0
- package/dist/docs/api/operations/check_table.md +29 -0
- package/dist/docs/api/operations/clone_table.md +48 -0
- package/dist/docs/api/operations/comment_on.md +42 -0
- package/dist/docs/api/operations/configure_database.md +52 -0
- package/dist/docs/api/operations/create_table.md +78 -0
- package/dist/docs/api/operations/create_view.md +54 -0
- package/dist/docs/api/operations/create_webhook.md +37 -0
- package/dist/docs/api/operations/define_base.md +52 -0
- package/dist/docs/api/operations/delete_rows.md +43 -0
- package/dist/docs/api/operations/delete_webhook.md +31 -0
- package/dist/docs/api/operations/describe_database.md +30 -0
- package/dist/docs/api/operations/describe_history.md +40 -0
- package/dist/docs/api/operations/describe_semantic_index.md +24 -0
- package/dist/docs/api/operations/describe_table.md +38 -0
- package/dist/docs/api/operations/docs.md +13 -0
- package/dist/docs/api/operations/drop_column.md +41 -0
- package/dist/docs/api/operations/drop_constraint.md +39 -0
- package/dist/docs/api/operations/drop_table.md +43 -0
- package/dist/docs/api/operations/drop_view.md +38 -0
- package/dist/docs/api/operations/engine_status.md +23 -0
- package/dist/docs/api/operations/graph_neighbors.md +32 -0
- package/dist/docs/api/operations/graph_path.md +32 -0
- package/dist/docs/api/operations/graph_traverse.md +43 -0
- package/dist/docs/api/operations/identify_session.md +24 -0
- package/dist/docs/api/operations/infer_table.md +43 -0
- package/dist/docs/api/operations/insert_row.md +48 -0
- package/dist/docs/api/operations/list_changes.md +35 -0
- package/dist/docs/api/operations/list_folder.md +28 -0
- package/dist/docs/api/operations/list_link_targets.md +44 -0
- package/dist/docs/api/operations/list_migrations.md +35 -0
- package/dist/docs/api/operations/list_tables.md +32 -0
- package/dist/docs/api/operations/list_webhooks.md +23 -0
- package/dist/docs/api/operations/manual_index.md +14 -0
- package/dist/docs/api/operations/manual_page.md +22 -0
- package/dist/docs/api/operations/merge_rows.md +44 -0
- package/dist/docs/api/operations/move_rows.md +52 -0
- package/dist/docs/api/operations/openapi.md +13 -0
- package/dist/docs/api/operations/openapi_post.md +20 -0
- package/dist/docs/api/operations/read_note.md +29 -0
- package/dist/docs/api/operations/recompute_columns.md +44 -0
- package/dist/docs/api/operations/record_tool_call.md +36 -0
- package/dist/docs/api/operations/rename_column.md +44 -0
- package/dist/docs/api/operations/rename_value.md +45 -0
- package/dist/docs/api/operations/restore_database.md +51 -0
- package/dist/docs/api/operations/restore_table.md +46 -0
- package/dist/docs/api/operations/search_notes.md +28 -0
- package/dist/docs/api/operations/select_rows.md +61 -0
- package/dist/docs/api/operations/semantic_search.md +34 -0
- package/dist/docs/api/operations/semantic_search_docs.md +26 -0
- package/dist/docs/api/operations/set_table_bases.md +44 -0
- package/dist/docs/api/operations/status.md +13 -0
- package/dist/docs/api/operations/stop_engine.md +23 -0
- package/dist/docs/api/operations/sync_semantic_index.md +33 -0
- package/dist/docs/api/operations/table_changes.md +31 -0
- package/dist/docs/api/operations/tags/auxiliary.md +14 -0
- package/dist/docs/api/operations/tags/change-feed.md +8 -0
- package/dist/docs/api/operations/tags/history.md +17 -0
- package/dist/docs/api/operations/tags/queries.md +15 -0
- package/dist/docs/api/operations/tags/rows-dml.md +16 -0
- package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
- package/dist/docs/api/operations/tags/service.md +15 -0
- package/dist/docs/api/operations/tags/tokens.md +13 -0
- package/dist/docs/api/operations/tokens_create.md +34 -0
- package/dist/docs/api/operations/tokens_delete.md +29 -0
- package/dist/docs/api/operations/tokens_list.md +21 -0
- package/dist/docs/api/operations/tokens_me.md +20 -0
- package/dist/docs/api/operations/tokens_rotate.md +29 -0
- package/dist/docs/api/operations/tokens_update.md +34 -0
- package/dist/docs/api/operations/undo_migration.md +46 -0
- package/dist/docs/api/operations/update_row.md +60 -0
- package/dist/docs/api/operations/update_rows.md +46 -0
- package/dist/docs/api/operations/vacuum_table.md +37 -0
- package/dist/docs/api.md +135 -0
- package/dist/docs/develop/build-an-app.md +320 -0
- package/dist/docs/develop/build-on-datanotes.md +138 -0
- package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
- package/dist/docs/develop/client.md +116 -0
- package/dist/docs/develop/concurrency.md +153 -0
- package/dist/docs/develop/http-api.md +79 -0
- package/dist/docs/develop/telemetry.md +86 -0
- package/dist/docs/guides/agents/docs-offline.md +99 -0
- package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
- package/dist/docs/guides/agents/prompts.md +495 -0
- package/dist/docs/guides/agents/reading-errors.md +112 -0
- package/dist/docs/guides/data-quality/check-constraints.md +379 -0
- package/dist/docs/guides/data-quality/check-table.md +63 -0
- package/dist/docs/guides/data-quality/hand-edits.md +507 -0
- package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
- package/dist/docs/guides/data-quality/validation.md +90 -0
- package/dist/docs/guides/database-objects/bases.md +480 -0
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
- package/dist/docs/guides/database-objects/columns.md +1332 -0
- package/dist/docs/guides/database-objects/relations.md +1454 -0
- package/dist/docs/guides/database-objects/tables.md +1404 -0
- package/dist/docs/guides/database-objects/views.md +1003 -0
- package/dist/docs/guides/history/back-up.md +195 -0
- package/dist/docs/guides/history/change-data-feed.md +247 -0
- package/dist/docs/guides/history/journal-and-undo.md +262 -0
- package/dist/docs/guides/history/restore.md +341 -0
- package/dist/docs/guides/history/table-history.md +657 -0
- package/dist/docs/guides/history/vacuum.md +35 -0
- package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
- package/dist/docs/guides/read-and-write/batch.md +139 -0
- package/dist/docs/guides/read-and-write/import-notes.md +896 -0
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
- package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
- package/dist/docs/guides/read-and-write/write-rows.md +573 -0
- package/dist/docs/guides/search/link-graph.md +146 -0
- package/dist/docs/guides/search/semantic.md +133 -0
- package/dist/docs/guides/search/text.md +142 -0
- package/dist/docs/guides/security/security-model.md +110 -0
- package/dist/docs/guides/security/tokens.md +60 -0
- package/dist/docs/guides/security/who-did-what.md +42 -0
- package/dist/docs/index.md +113 -0
- package/dist/docs/llms.txt +33 -0
- package/dist/docs/reference/cli.md +136 -0
- package/dist/docs/reference/compatibility.md +63 -0
- package/dist/docs/reference/errors.md +72 -0
- package/dist/docs/reference/glossary.md +161 -0
- package/dist/docs/reference/operations/auxiliary.md +116 -0
- package/dist/docs/reference/operations/history.md +168 -0
- package/dist/docs/reference/operations/queries.md +169 -0
- package/dist/docs/reference/operations/rows.md +185 -0
- package/dist/docs/reference/operations/schema.md +316 -0
- package/dist/docs/reference/operations.md +96 -0
- package/dist/docs/reference/settings.md +31 -0
- package/dist/docs/release-notes.md +67 -0
- package/dist/docs/start/connect-agents.md +204 -0
- package/dist/docs/start/how-it-works.md +317 -0
- package/dist/docs/start/quick-start.md +126 -0
- package/package.json +59 -14
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Settings
|
|
2
|
+
|
|
3
|
+
> Every key of the engine's settings file and its default.
|
|
4
|
+
|
|
5
|
+
The headless engine reads `settings.json` in its store, outside the vault (`datanotes store path` shows where), or the file given with `--settings`. Missing keys take their default.
|
|
6
|
+
|
|
7
|
+
| Key | Default | Meaning |
|
|
8
|
+
| ---------------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `journalRetentionDays` | `90` | Journal entries older than this many days are dropped (undo is no longer possible for them). |
|
|
10
|
+
| `fileLogEnabled` | `true` | Write log records to `logs/<day>.<source>.jsonl` in the engine’s store. |
|
|
11
|
+
| `logRetentionDays` | `30` | Log files older than this many days are deleted. |
|
|
12
|
+
| `tableKey` | `"table"` | Row property naming the catalog table a note belongs to (`table: personal.metrics.mood`). |
|
|
13
|
+
| `telemetryEnabled` | `false` | Send the engine’s logs to an OpenTelemetry collector or OTLP backend (OTLP/HTTP). |
|
|
14
|
+
| `telemetryEndpoint` | `"http://127.0.0.1:4318"` | OTLP/HTTP base URL; logs are POSTed to `<endpoint>/v1/logs`. |
|
|
15
|
+
| `telemetryServiceName` | `"datanotes"` | `service.name` resource attribute. |
|
|
16
|
+
| `telemetryHeaders` | `{}` | HTTP headers sent with every export: the API key or `Authorization` the backend asks for. Kept in the settings file; `OTEL_EXPORTER_OTLP_HEADERS` adds to them. |
|
|
17
|
+
| `telemetryProtocol` | `"http/protobuf"` | OTLP encoding: `http/protobuf` (the OpenTelemetry default) or `http/json`. |
|
|
18
|
+
| `autoRecompute` | `true` | After a row is edited by hand, recompute its generated / identity columns (a few seconds after the last change, as a journaled `recompute_columns` operation). |
|
|
19
|
+
| `repairLinksOnHandMove` | `true` | Rewrite the links to a note renamed or moved by hand (in a file manager, with git or a sync tool), across the vault, once the vault has been quiet for 4 s and not while git pulls, rebases or merges. The repair is one journaled `repair_links` operation that undo takes back. Links an editor already rewrote stay as they are. |
|
|
20
|
+
| `semanticEnabled` | `false` | Semantic search: embed notes with `semanticProvider` (off by default: content is sent to it). |
|
|
21
|
+
| `semanticProvider` | `"ollama"` | Embedding provider: `ollama`, `lmstudio`, `openrouter`, `openai` or `custom` (any OpenAI-compatible API). |
|
|
22
|
+
| `semanticBaseUrl` | `""` | Empty: the provider’s default URL. |
|
|
23
|
+
| `semanticModel` | `""` | Embedding model, e.g. `nomic-embed-text` (Ollama) or `openai/text-embedding-3-small` (OpenRouter). |
|
|
24
|
+
| `semanticScope` | `"vault"` | “vault”: every note; “tables”: only table rows. |
|
|
25
|
+
| `semanticExclude` | `[]` | Folders left out of the index. |
|
|
26
|
+
| `semanticBatchSize` | `32` | Passages per embedding request. |
|
|
27
|
+
| `httpServerPort` | `27150` | Port of the HTTP API (on 127.0.0.1 unless the service is told otherwise): 1024 to 65535, or 0 for any free port. Any other value stops the engine from starting. |
|
|
28
|
+
| `httpServerToken` | `""` | The owner’s bearer token (generated at the first start). |
|
|
29
|
+
| `storeBackupEnabled` | `false` | Back up the engine’s store to a git repository: commits as `storeBackupIntervalSeconds` says, each pushed to `storeBackupRemote` (headless engine; `datanotes store backup` sets it). |
|
|
30
|
+
| `storeBackupRemote` | `""` | The git remote the store backup pushes to, such as a private GitHub repository. Empty: commits in the store only, nothing pushed. |
|
|
31
|
+
| `storeBackupIntervalSeconds` | `60` | How often the store backup looks for changes, in seconds (at least 10): when something changed, it commits between two operations (a consistent snapshot), then pushes. |
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Release notes
|
|
2
|
+
|
|
3
|
+
> What each version of Datanotes brings, newest first, starting with 3.0.0.
|
|
4
|
+
|
|
5
|
+
This page lists each version of Datanotes, newest first. Datanotes follows [semantic versioning](https://semver.org): a major version can break what you rely on, and its notes list those changes first. The package is on [npm](https://www.npmjs.com/package/datanotes), and each version has a [GitHub release](https://github.com/davidefornelli/datanotes/releases).
|
|
6
|
+
|
|
7
|
+
## 3.0.0
|
|
8
|
+
|
|
9
|
+
Datanotes 3.0.0 is the first stable release. Versions 1.x and 2.x, published on 7 and 8 October 2026, were previews. Datanotes runs a folder of Markdown notes as typed database tables. You reach it through an HTTP API, a command line and an MCP server for agents.
|
|
10
|
+
|
|
11
|
+
### Tables and the metastore
|
|
12
|
+
|
|
13
|
+
* **One metastore per vault**: `metastore.yaml` defines the tables, views and bases. Only operations change it, and each change is validated and journaled. The engine refuses a vault with more than one `metastore.yaml`.
|
|
14
|
+
* **The database folder**: a new database goes to `datanotes/`. The engine finds the folder by its `metastore.yaml`, whatever its name. See [Move the vault or the database folder](https://datanotes.dev/start/how-it-works/#move-the-vault-or-the-database-folder).
|
|
15
|
+
* **Descriptions**: `create_table`, `add_column`, `clone_table` and `define_base` require a description for each table, base and column. A refusal lists every missing one. See [Describe every table and column](https://datanotes.dev/guides/database-objects/tables/#describe-every-table-and-column).
|
|
16
|
+
* **CHECK constraints that follow links**: a CHECK such as `{"parent.kind": "project"}` tests the linked row.
|
|
17
|
+
* **Filtered link targets**: `ref_where` and `ref_by` limit what a link may point to, and `list_link_targets` lists those rows.
|
|
18
|
+
* **Hand edits are checked**: the engine checks notes edited outside it against the tables’ rules. The change feed, the transaction log and the log report what they break.
|
|
19
|
+
* **Schema operations for hand-written metastores**: table `tags`, `alter_table` with `archive` and `fields`, and `comment_on` for catalogs and schemas.
|
|
20
|
+
* **`select_rows` with `this_note`**: fills a view’s `{this.*}` tokens from a note, so one view serves every daily note.
|
|
21
|
+
|
|
22
|
+
### The store and its backup
|
|
23
|
+
|
|
24
|
+
* **The store is outside the vault**: settings, tokens, journal, transaction logs, change feed, semantic index, logs and lock live in `<data home>/<database id>/`. See [Where the engine keeps its store](https://datanotes.dev/administration/run-the-service/#where-the-engine-keeps-its-store).
|
|
25
|
+
* **A database id**: the engine writes an `id` line at the top of `metastore.yaml` and finds the store by it.
|
|
26
|
+
* **`datanotes store`**: `datanotes store path` shows where a vault’s store is. `datanotes store new-id` gives a copied database its own id and store.
|
|
27
|
+
* **Store backup**: the engine keeps its store in a git repository of its own and pushes it to a private remote. Each commit is a consistent snapshot, and the secrets stay out. `datanotes store restore` brings the store back on a new machine. See [Back up the history](https://datanotes.dev/guides/history/back-up/).
|
|
28
|
+
* **`--store` and `DATANOTES_DATA_HOME`**: place the store and move the data home. The Docker image keeps the store in `/data`.
|
|
29
|
+
|
|
30
|
+
### History and undo
|
|
31
|
+
|
|
32
|
+
* **The journal**: every write is journaled, and `undo_migration` reverts it. An undo of an undo is a redo, and a `batch` is one entry.
|
|
33
|
+
* **History on in a new database**: a database the engine creates gets `history: true` in its `metastore.yaml`, so every table keeps its versions. A database without the setting keeps history off. See [The transaction log keeps every version](https://datanotes.dev/start/how-it-works/#the-transaction-log-keeps-every-version).
|
|
34
|
+
* **History for the whole database**: `restore_database` brings every table back to a time, or to the moment before an operation.
|
|
35
|
+
* **Time travel**: `describe_history` without `table` lists the commits of every table. `select_rows` with `timestamp` reads views, joins and bases as they were.
|
|
36
|
+
* **Moves of the database folder**: a move by hand or with `configure_database` is one operation. Undo and time travel read what came before it with the new paths.
|
|
37
|
+
|
|
38
|
+
### Notes and links
|
|
39
|
+
|
|
40
|
+
* **Automatic links**: a write links the notes its text mentions by name, at their first mention. `links_added` lists them, and `ambiguous_mentions` returns the doubtful ones for the agent to decide. See [Automatic links](https://datanotes.dev/guides/read-and-write/automatic-links/).
|
|
41
|
+
* **Safe on a large vault**: a one-word name links only when capitalized and not at the start of a sentence. Names inside paths, domains and snake_case words stay as they are.
|
|
42
|
+
* **`autolink_target`**: a table option that says whether automatic links may point to its rows. See [Choose the tables a link may point to](https://datanotes.dev/guides/read-and-write/automatic-links/#choose-the-tables-a-link-may-point-to).
|
|
43
|
+
* **Links follow a note renamed by hand**: the engine rewrites every link to its old path, in one `repair_links` operation that undo takes back. See [The engine repairs links after a hand move](https://datanotes.dev/start/how-it-works/#the-engine-repairs-links-after-a-hand-move).
|
|
44
|
+
* **A note moved by hand is a rename**: a note gone and a new one with its text, seen at once, are one rename.
|
|
45
|
+
|
|
46
|
+
### Agents
|
|
47
|
+
|
|
48
|
+
* **`datanotes mcp`**: the MCP server ships in the `datanotes` package. [Connect your agents](https://datanotes.dev/start/connect-agents/) shows how to configure it.
|
|
49
|
+
* **`datanotes/mcp`**: the engine’s operations as MCP tool definitions for an MCP server of your own. See [Build on Datanotes](https://datanotes.dev/develop/build-on-datanotes/).
|
|
50
|
+
* **Docs offline**: the package ships these docs as Markdown. Agents read them with `list_docs`, `read_docs` and `search_docs`. The `Docs:` line of an error names the `read_docs` call, so the agent reads the section without internet access. Your own MCP server does the same with `offlineDocs`. See [Read the docs offline](https://datanotes.dev/guides/agents/docs-offline/).
|
|
51
|
+
* **Hybrid search of the docs**: `search_docs` merges a ranking by words with one by meaning. See [Search by words and by meaning](https://datanotes.dev/guides/agents/docs-offline/#search-by-words-and-by-meaning).
|
|
52
|
+
* **Errors that teach**: every error says what is wrong, how to fix it in `hint`, and where to read more in `docs`. See [Errors](https://datanotes.dev/reference/errors/).
|
|
53
|
+
|
|
54
|
+
### Security
|
|
55
|
+
|
|
56
|
+
* **Named tokens**: each program gets a token of its own, with the tables it may read and write. A token’s `autolink` sets the default of its writes. See [Turn automatic links off for a sync program](https://datanotes.dev/guides/security/tokens/#turn-automatic-links-off-for-a-sync-program).
|
|
57
|
+
* **The actor**: every write records who made it, with `auth` set to `owner` or the token’s name.
|
|
58
|
+
* **No secret in the change feed**: a recorded tool call loses webhook secrets and values under keys such as `token` or `password`.
|
|
59
|
+
|
|
60
|
+
### Running the engine
|
|
61
|
+
|
|
62
|
+
* **Node.js 22 or newer**: the engine and the command line need Node.js 22 or later.
|
|
63
|
+
* **`datanotes serve --port`**: the port for one run, also as `DATANOTES_PORT`. With `--port 0`, the system picks a free port. See [Choose the port](https://datanotes.dev/administration/run-the-service/#choose-the-port).
|
|
64
|
+
* **`datanotes status`**: the engine’s health at a glance. See [Check the engine’s status](https://datanotes.dev/administration/status/).
|
|
65
|
+
* **`datanotes stop`**: a graceful stop. The engine finishes its requests, makes its last git sync and backup push, and releases its lock. See [Stop the engine](https://datanotes.dev/administration/run-the-service/#stop-the-engine).
|
|
66
|
+
* **One engine per database**: the engine holds a lock in its store and checks the lock’s process on the same machine.
|
|
67
|
+
* **Git never waits for a person**: git sync and the store backup run git without prompts, and with time limits. See [Git never waits for a person](https://datanotes.dev/administration/git-sync/#git-never-waits-for-a-person).
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# Connect your agents to a vault
|
|
2
|
+
|
|
3
|
+
> Configure Claude, Cursor, Codex and other MCP clients with datanotes mcp, the Model Context Protocol server of Datanotes.
|
|
4
|
+
|
|
5
|
+
Agents such as Claude, Cursor and Codex reach your vault through the Model Context Protocol (MCP) server of Datanotes, the `datanotes mcp` command. This page shows how to:
|
|
6
|
+
|
|
7
|
+
* Start the server for an agent on your computer
|
|
8
|
+
* Serve it over HTTP to more than one agent
|
|
9
|
+
* Choose the tools each agent sees
|
|
10
|
+
* Give each agent its own token and see what it changed
|
|
11
|
+
* Protect your database from prompt injection
|
|
12
|
+
|
|
13
|
+
## How the MCP server reaches the engine
|
|
14
|
+
|
|
15
|
+
`datanotes mcp` ships in the `datanotes` package and runs as its own process, apart from the engine. It offers the [operations](https://datanotes.dev/reference/operations/) as MCP tools, all but the webhook tools [unless you add them](#choose-the-tools-an-agent-sees), plus `list_docs`, `read_docs` and `search_docs`, which [read the docs](#read-the-docs-offline) of the installed version. Tools of other programs come from their own MCP servers, as [Build on Datanotes](https://datanotes.dev/develop/build-on-datanotes/) explains. Each tool call becomes a request to the engine’s [HTTP API](https://datanotes.dev/develop/http-api/) with the agent’s token. The engine then checks what the token may do and records who did what.
|
|
16
|
+
|
|
17
|
+
An MCP client starts the server in one of two ways:
|
|
18
|
+
|
|
19
|
+
* **Standard input and output (stdio)**: the client starts `datanotes mcp` itself, on the computer that holds the vault
|
|
20
|
+
* **HTTP**: the client calls `/mcp` on a running `datanotes mcp serve` and sends a bearer token; use it for more than one client at once, or for a hosted assistant that can send a custom `Authorization` header (the server offers no OAuth)
|
|
21
|
+
|
|
22
|
+
## Connect an agent on your computer
|
|
23
|
+
|
|
24
|
+
You need [Node.js](https://nodejs.org) 22 or newer. On Windows, use Node.js 24.16 or later, or 26.1 or later. Node.js 24.0 to 24.15 and 26.0 can crash at random on local connections. `datanotes mcp` warns at start on those versions.
|
|
25
|
+
|
|
26
|
+
With `--database` or `--vault`, `datanotes mcp` uses the engine that runs on that folder. Give the same option as `datanotes serve`. When no engine runs, it starts one with `datanotes serve`. When the client closes, it asks that engine to stop, as `datanotes stop` does. The engine finishes its writes and releases the folder. Only an engine still running after 35 seconds is killed.
|
|
27
|
+
|
|
28
|
+
It acts with the owner’s token from the engine’s settings, in its store, so the agent has full rights. To limit an agent, use one of these:
|
|
29
|
+
|
|
30
|
+
* [Choose its tools](#choose-the-tools-an-agent-sees) with `--profile`, `--tools` or `--except`
|
|
31
|
+
* Give it a [named token](#give-each-agent-its-own-token) with `--url` and `--token-file`
|
|
32
|
+
* Connect it over HTTP with its own token
|
|
33
|
+
|
|
34
|
+
The agent waits while the engine starts, for up to 60 seconds. A large database takes longer to start. Set `DATANOTES_ENGINE_START_TIMEOUT_S` to wait longer. Above about 20,000 notes, run `datanotes serve` as a service instead, as [Limits](https://datanotes.dev/administration/limits/#start-the-engine-before-the-agent) explains.
|
|
35
|
+
|
|
36
|
+
Add the server to Claude Code with one command:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
claude mcp add datanotes -- \
|
|
40
|
+
npx -y datanotes mcp --database your_database_folder
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Claude Desktop, Cursor and other clients with an `mcpServers` file take the same command and arguments:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"mcpServers": {
|
|
48
|
+
"datanotes": {
|
|
49
|
+
"command": "npx",
|
|
50
|
+
"args": [
|
|
51
|
+
"-y", "datanotes", "mcp", "--database", "your_database_folder"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Codex reads its MCP servers from `~/.codex/config.toml`:
|
|
59
|
+
|
|
60
|
+
```toml
|
|
61
|
+
[mcp_servers.datanotes]
|
|
62
|
+
command = "npx"
|
|
63
|
+
args = ["-y", "datanotes", "mcp", "--database", "your_database_folder"]
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
On Windows, escape the backslashes in JSON and TOML (`C:\\Notes\\Films`). Claude Code on Windows, outside Windows Subsystem for Linux (WSL), starts `npx` through `cmd`:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
claude mcp add datanotes -- cmd /c npx -y datanotes mcp --database C:\Notes
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To use an engine at an address instead of a local folder, pass the address and a file that contains the token:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx -y datanotes mcp --url https://datanotes.example.com \
|
|
76
|
+
--token-file ~/.datanotes-token
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Serve agents over HTTP
|
|
80
|
+
|
|
81
|
+
`datanotes mcp serve` serves MCP over Streamable HTTP at `/mcp`. Run it next to the engine:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx -y datanotes mcp serve --url http://127.0.0.1:27150 --port 27151
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Clients connect to `http://127.0.0.1:27151/mcp` and send their own token. Add it to Claude Code with:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
claude mcp add --transport http datanotes http://127.0.0.1:27151/mcp \
|
|
91
|
+
--header "Authorization: Bearer your_agent_token"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Cursor and the `.mcp.json` file of Claude Code take the address and the header:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"datanotes": {
|
|
100
|
+
"type": "http",
|
|
101
|
+
"url": "http://127.0.0.1:27151/mcp",
|
|
102
|
+
"headers": { "Authorization": "Bearer your_agent_token" }
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The server keeps no credentials: it passes the token of each request to the engine, and refuses a token the engine doesn’t accept. `GET /` answers its status without a token. To reach the server from another device, publish only `/mcp` through a reverse proxy or a tunnel, over HTTPS, as [Security](https://datanotes.dev/guides/security/security-model/) explains.
|
|
109
|
+
|
|
110
|
+
## Choose the tools an agent sees
|
|
111
|
+
|
|
112
|
+
By default, `datanotes mcp` offers every tool except `create_webhook` and `delete_webhook`. A webhook sends your database’s changes, and with `since` its past ones too, to any web address. So an agent gets these two tools only when you add them. Both stdio and `serve` take the same options:
|
|
113
|
+
|
|
114
|
+
| Option | What the agent sees |
|
|
115
|
+
| ----------------- | -------------------------------------------------------------------------------------- |
|
|
116
|
+
| None | Every tool except `create_webhook` and `delete_webhook` |
|
|
117
|
+
| `--profile read` | Only the tools that read: `select_rows`, `describe_table`, the docs tools and the like |
|
|
118
|
+
| `--profile write` | Every tool except the schema changes, `configure_database` and the webhook tools |
|
|
119
|
+
| `--profile all` | Every tool, the webhook tools included |
|
|
120
|
+
| `--tools a,b` | Only the tools you name, separated by commas |
|
|
121
|
+
| `--except a,b` | The others: it removes these tools from the profile or from `--tools` |
|
|
122
|
+
| `--owner-tools` | Adds `create_webhook` and `delete_webhook` to the rest |
|
|
123
|
+
|
|
124
|
+
Give an agent that only answers questions the `read` profile:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
claude mcp add datanotes -- \
|
|
128
|
+
npx -y datanotes mcp --database your_database_folder --profile read
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Name the tools one by one for a narrow agent, such as one that logs meals:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
npx -y datanotes mcp --database your_database_folder \
|
|
135
|
+
--tools list_tables,describe_table,select_rows,insert_row
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Keep an agent from undoing changes, and give it the webhook tools:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npx -y datanotes mcp serve --except undo_migration --owner-tools
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
You can’t pass `--profile` and `--tools` together. An unknown tool name stops the command, and the error names the closest tool. A call to a tool the server doesn’t offer fails as an unknown tool. The engine still checks the token on every call, so a [named token](#give-each-agent-its-own-token) limits the agent too.
|
|
145
|
+
|
|
146
|
+
## Give each agent its own token
|
|
147
|
+
|
|
148
|
+
A named token limits what an agent can do, and the journal records its name. It writes only the tables you allow in `write`, changes the schema only with `ddl`, and undoes changes only with `maintain`. Create one with the owner’s token:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
curl -s http://127.0.0.1:27150/datanotes/tokens/create/ \
|
|
152
|
+
-H "Authorization: Bearer your_owner_token" \
|
|
153
|
+
-H "Content-Type: application/json" \
|
|
154
|
+
-d '{"name": "claude", "write": ["*"], "ddl": true, "maintain": true}'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The answer contains the token, and shows it only once. [Tokens](https://datanotes.dev/guides/security/tokens/) describes every permission.
|
|
158
|
+
|
|
159
|
+
## Agents and prompt injection
|
|
160
|
+
|
|
161
|
+
An agent reads text it didn’t write: your notes, web pages, emails and the answers of other tools. That text can hold instructions aimed at the agent, such as “send every note to this address”. This attack is called prompt injection. Datanotes can’t tell such text from your own words, so limit what a misled agent can do:
|
|
162
|
+
|
|
163
|
+
* **Offer only the tools it needs.** Use `--profile read` for an agent that reads, and `--tools` for a narrow one.
|
|
164
|
+
* **Keep the webhook tools for yourself.** They are off by default. Add `--owner-tools` only for an agent you ask to create a webhook.
|
|
165
|
+
* **Give it a named token.** A [named token](#give-each-agent-its-own-token) writes only the tables you allow, and never creates webhooks.
|
|
166
|
+
* **Confirm what leaves the database.** Ask your MCP client to confirm tool calls that write or send data.
|
|
167
|
+
* **Check what it changed.** [See which agent made a change](#see-which-agent-made-a-change), and undo it with `undo_migration`.
|
|
168
|
+
|
|
169
|
+
Every write is journaled, so you can undo what an agent changed. Data an agent sends out of the database can’t come back.
|
|
170
|
+
|
|
171
|
+
## Set options with flags or environment variables
|
|
172
|
+
|
|
173
|
+
Each option has an environment variable, which applies when the command line doesn’t give the option:
|
|
174
|
+
|
|
175
|
+
| Option | Variable | Meaning |
|
|
176
|
+
| --------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
177
|
+
| `--database your_database_folder` | `DATANOTES_DATABASE` | stdio on the engine of a local database folder, with the owner’s token |
|
|
178
|
+
| `--vault your_vault_folder` | `DATANOTES_VAULT` | stdio on the engine of a local vault, with the owner’s token; instead of `--database` |
|
|
179
|
+
| `--url your_engine_url` | `DATANOTES_URL` | stdio on the engine at this address |
|
|
180
|
+
| `--token-file your_token_file` | `DATANOTES_TOKEN_FILE`, or the token itself in `DATANOTES_TOKEN` | The token for `--url` |
|
|
181
|
+
| `serve --url your_engine_url` | `DATANOTES_URL` | The engine behind the HTTP server; default `http://127.0.0.1:27150` |
|
|
182
|
+
| `serve --host your_address` | `DATANOTES_MCP_HOST` | The address the HTTP server listens on; default `127.0.0.1` |
|
|
183
|
+
| `serve --port 27151` | `DATANOTES_MCP_PORT` | The port of the HTTP server; default `27151` |
|
|
184
|
+
| `--profile read` | `DATANOTES_MCP_PROFILE` | The [tools](#choose-the-tools-an-agent-sees) to offer: `read`, `write` or `all` |
|
|
185
|
+
| `--tools a,b` | `DATANOTES_MCP_TOOLS` | Only these tools, separated by commas; instead of `--profile` |
|
|
186
|
+
| `--except a,b` | `DATANOTES_MCP_EXCEPT` | None of these tools, separated by commas |
|
|
187
|
+
| `--owner-tools` | `DATANOTES_MCP_OWNER_TOOLS=1` | Also offer `create_webhook` and `delete_webhook` |
|
|
188
|
+
| `--otlp-endpoint your_endpoint` | `OTEL_EXPORTER_OTLP_ENDPOINT` | The OpenTelemetry Protocol (OTLP) collector that receives the logs |
|
|
189
|
+
| None | `DATANOTES_DOCS_DIR` | The folder of the docs that `list_docs`, `read_docs` and `search_docs` read; default: the ones in the package |
|
|
190
|
+
| None | `DATANOTES_ENGINE_START_TIMEOUT_S` | Seconds `--database` waits for the engine it starts; default `60` |
|
|
191
|
+
|
|
192
|
+
`datanotes mcp --help` prints the same list, and [Command line](https://datanotes.dev/reference/cli/) shows every command of `datanotes`.
|
|
193
|
+
|
|
194
|
+
## Read the docs offline
|
|
195
|
+
|
|
196
|
+
The `datanotes` package ships this documentation as Markdown, for the installed version. Agents read it with `list_docs`, `read_docs` and `search_docs`, programs through the engine, and people in `node_modules/datanotes/dist/docs/`: [Read the docs offline](https://datanotes.dev/guides/agents/docs-offline/) shows each way.
|
|
197
|
+
|
|
198
|
+
## Send the server’s logs to your backend
|
|
199
|
+
|
|
200
|
+
`datanotes mcp` sends its logs with OpenTelemetry when `OTEL_EXPORTER_OTLP_ENDPOINT` or `--otlp-endpoint` names a collector. The records cover tool calls, refused requests and sessions, and never contain tokens or argument values. [Logs and telemetry](https://datanotes.dev/develop/telemetry/) shows how to set up the backend.
|
|
201
|
+
|
|
202
|
+
## See which agent made a change
|
|
203
|
+
|
|
204
|
+
Every write records its actor: the client’s name from the MCP handshake, its session, the tool, and the credential as `auth` (`owner`, or the token’s name). An MCP server of your own can also report the agent’s model with `POST /datanotes/sessions/identify/`. `list_migrations` shows who made each change in its `by` field, and `list_changes` shows the full actor of every change and tool call.
|