Connect your agents to a vault
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:
- Start the server for an agent on your computer
- Serve it over HTTP to more than one agent
- Choose the tools each agent sees
- Give each agent its own token and see what it changed
- Protect your database from prompt injection
How the MCP server reaches the engine
Section titled “How the MCP server reaches the engine”datanotes mcp ships in the datanotes package and runs as its own process, apart from the engine. It offers the operations as MCP tools, all but the webhook tools unless you add them, plus list_docs, read_docs and search_docs, which read the docs of the installed version. Tools of other programs come from their own MCP servers, as Build on Datanotes explains. Each tool call becomes a request to the engine’s HTTP API with the agent’s token. The engine then checks what the token may do and records who did what.
An MCP client starts the server in one of two ways:
- Standard input and output (stdio): the client starts
datanotes mcpitself, on the computer that holds the vault - HTTP: the client calls
/mcpon a runningdatanotes mcp serveand sends a bearer token; use it for more than one client at once, or for a hosted assistant that can send a customAuthorizationheader (the server offers no OAuth)
Connect an agent on your computer
Section titled “Connect an agent on your computer”You need Node.js 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.
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.
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:
- Choose its tools with
--profile,--toolsor--except - Give it a named token with
--urland--token-file - Connect it over HTTP with its own token
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 explains.
Add the server to Claude Code with one command:
claude mcp add datanotes -- \ npx -y datanotes mcp --database your_database_folderClaude Desktop, Cursor and other clients with an mcpServers file take the same command and arguments:
{ "mcpServers": { "datanotes": { "command": "npx", "args": [ "-y", "datanotes", "mcp", "--database", "your_database_folder" ] } }}Codex reads its MCP servers from ~/.codex/config.toml:
[mcp_servers.datanotes]command = "npx"args = ["-y", "datanotes", "mcp", "--database", "your_database_folder"]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:
claude mcp add datanotes -- cmd /c npx -y datanotes mcp --database C:\NotesTo use an engine at an address instead of a local folder, pass the address and a file that contains the token:
npx -y datanotes mcp --url https://datanotes.example.com \ --token-file ~/.datanotes-tokenServe agents over HTTP
Section titled “Serve agents over HTTP”datanotes mcp serve serves MCP over Streamable HTTP at /mcp. Run it next to the engine:
npx -y datanotes mcp serve --url http://127.0.0.1:27150 --port 27151Clients connect to http://127.0.0.1:27151/mcp and send their own token. Add it to Claude Code with:
claude mcp add --transport http datanotes http://127.0.0.1:27151/mcp \ --header "Authorization: Bearer your_agent_token"Cursor and the .mcp.json file of Claude Code take the address and the header:
{ "mcpServers": { "datanotes": { "type": "http", "url": "http://127.0.0.1:27151/mcp", "headers": { "Authorization": "Bearer your_agent_token" } } }}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 explains.
Choose the tools an agent sees
Section titled “Choose the tools an agent sees”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:
| Option | What the agent sees |
|---|---|
| None | Every tool except create_webhook and delete_webhook |
--profile read |
Only the tools that read: select_rows, describe_table, the docs tools and the like |
--profile write |
Every tool except the schema changes, configure_database and the webhook tools |
--profile all |
Every tool, the webhook tools included |
--tools a,b |
Only the tools you name, separated by commas |
--except a,b |
The others: it removes these tools from the profile or from --tools |
--owner-tools |
Adds create_webhook and delete_webhook to the rest |
Give an agent that only answers questions the read profile:
claude mcp add datanotes -- \ npx -y datanotes mcp --database your_database_folder --profile readName the tools one by one for a narrow agent, such as one that logs meals:
npx -y datanotes mcp --database your_database_folder \ --tools list_tables,describe_table,select_rows,insert_rowKeep an agent from undoing changes, and give it the webhook tools:
npx -y datanotes mcp serve --except undo_migration --owner-toolsYou 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 limits the agent too.
Tools of extensions
Section titled “Tools of extensions”An installed extension adds its own tools. datanotes mcp offers them after the engine’s tools, in stdio and in serve. The docs tools serve its docs under extensions/<name>/.
- After an install: restart the MCP server, or the client that started it. A running server does not see a new extension.
--no-extensions: leaves the extension tools out.DATANOTES_MCP_EXTENSIONS=0does the same.--profile read: keeps only the extensions’ tools that read.--toolsand--except: name engine and docs tools only.
The engine still checks the token on every call. A tool that writes also needs a client token that may write its tables.
Give each agent its own token
Section titled “Give each agent its own token”A named token limits what an agent can do, and the journal records its name. It has these limits:
- Reads: only the tables you allow in
read; withoutread, every table - Writes: only the tables you allow in
write - Schema changes: only with
ddl - Undo: only with
maintain
Create one with the owner’s token. This one reads and writes every table, changes the schema and may undo:
curl -s http://127.0.0.1:27150/datanotes/tokens/create/ \ -H "Authorization: Bearer your_owner_token" \ -H "Content-Type: application/json" \ -d '{"name": "claude", "write": ["*"], "ddl": true, "maintain": true}'The answer contains the token, and shows it only once. Tokens describes every permission. To keep an agent to some tables, give it read patterns, as Limit what a token can read shows.
Agents and prompt injection
Section titled “Agents and prompt injection”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:
- Offer only the tools it needs. Use
--profile readfor an agent that reads, and--toolsfor a narrow one. - Keep the webhook tools for yourself. They are off by default. Add
--owner-toolsonly for an agent you ask to create a webhook. - Give it a named token. A named token reads and writes only the tables you allow. It never creates webhooks.
- Confirm what leaves the database. Ask your MCP client to confirm tool calls that write or send data.
- Check what it changed. See which agent made a change, and undo it with
undo_migration.
Every write is journaled, so you can undo what an agent changed. Data an agent sends out of the database can’t come back.
Set options with flags or environment variables
Section titled “Set options with flags or environment variables”Each option has an environment variable, which applies when the command line doesn’t give the option:
| Option | Variable | Meaning |
|---|---|---|
--database your_database_folder |
DATANOTES_DATABASE |
stdio on the engine of a local database folder, with the owner’s token |
--vault your_vault_folder |
DATANOTES_VAULT |
stdio on the engine of a local vault, with the owner’s token; instead of --database |
--url your_engine_url |
DATANOTES_URL |
stdio on the engine at this address |
--token-file your_token_file |
DATANOTES_TOKEN_FILE, or the token itself in DATANOTES_TOKEN |
The token for --url |
serve --url your_engine_url |
DATANOTES_URL |
The engine behind the HTTP server; default http://127.0.0.1:27150 |
serve --host your_address |
DATANOTES_MCP_HOST |
The address the HTTP server listens on; default 127.0.0.1 |
serve --port 27151 |
DATANOTES_MCP_PORT |
The port of the HTTP server; default 27151 |
--profile read |
DATANOTES_MCP_PROFILE |
The tools to offer: read, write or all |
--tools a,b |
DATANOTES_MCP_TOOLS |
Only these tools, separated by commas; instead of --profile |
--except a,b |
DATANOTES_MCP_EXCEPT |
None of these tools, separated by commas |
--owner-tools |
DATANOTES_MCP_OWNER_TOOLS=1 |
Also offer create_webhook and delete_webhook |
--otlp-endpoint your_endpoint |
OTEL_EXPORTER_OTLP_ENDPOINT |
The OpenTelemetry Protocol (OTLP) collector that receives the logs |
| None | DATANOTES_DOCS_DIR |
The folder of the docs that list_docs, read_docs and search_docs read; default: the ones in the package |
| None | DATANOTES_ENGINE_START_TIMEOUT_S |
Seconds --database waits for the engine it starts; default 60 |
datanotes mcp --help prints the same list, and Command line shows every command of datanotes.
Read the docs offline
Section titled “Read the docs offline”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 shows each way.
Send the server’s logs to your backend
Section titled “Send the server’s logs to your backend”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 shows how to set up the backend.
See which agent made a change
Section titled “See which agent made a change”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.