Guides · Agents & copilots
Coding agents
Set up a repository so a coding agent reads your schema, checks each new query before saving and keeps no secret in git.
- API
- —
- In the schema
- —
What you’ll build#
You will connect a coding agent such as Claude Code or Cursor so it reads your live schema, type-checks every query before saving and keeps secrets out of git across four guarantees.
- The agent knows the conventions
- Your repository documents the layout of a Napalm project: schema, deployed queries, access policies and generated client.
- Queries are checked first
- The agent compiles each candidate EdgeQL statement against your live schema before writing the query file.
- No secret in git
- Committed MCP configs invoke
napalm mcp, reading your key from local CLI config rather than repository files. - The agent cannot do damage
- The agent starts with a
--read-onlykey while schema pushes and query deploys stay in your terminal.
Before you start#
You need a project and the napalm CLI signed in with napalm login. Use any editor or coding agent with MCP support, such as Claude Code, Cursor or VS Code.
Set the repository up#
Three CLI commands wire your repository to the project’s MCP tools while keeping every service key outside version control.
Zero-secret repo wiring via napalm init and napalm mcp
napalm init writes project conventions into AGENTS.md and registers napalm mcp <project> in .mcp.json, relaying stdio tool calls with the --read-only key stored in your local CLI config.
# In your repository: the agent's instructions, and its connection to the project.napalm init notes # A key for it, kept in this machine's config and never in the repository.napalm keys create notes --label coding-agent --read-only --save # Let it read the schema and check queries against it.napalm endpoint notes --share-schema- Instructions
napalm initwrites a Napalm section intoAGENTS.mdand makesCLAUDE.mdimportAGENTS.md. Runnapalm initagain after an upgrade to update only the Napalm section.- The connection
napalm initalso registers the project in.mcp.json,.cursor/mcp.jsonand.vscode/mcp.jsonusingnapalm mcp notes. Those files hold zero secrets and are safe to commit.- The key
--savestores the key in your local CLI config wherenapalm mcpreads it automatically. Each teammate creates a separate key.
{ "mcpServers": { "notes": { "command": "napalm", "args": ["mcp", "notes"] } }}Learn the agent’s tools#
Sharing the schema unlocks compiler-backed MCP tools so the agent validates types, access rules and query plans before saving files.
| Tool | Purpose |
|---|---|
describe_schema | Reads your types, links and access rules as written. |
check_query | Compiles a statement against the schema and proves whether the statement reads or writes, or returns the compile error. Nothing runs. |
explain_query | Reports a statement’s cost: run count and duration, or the planner’s estimate for a statement that has not run. |
query | Runs a statement and returns the rows. A read-only key cannot write. |
describe_reach | Counts the rows the active key can read, change and delete in each type. |
read_changes | Reads the change log since a given time, as visible to the active key. |
| Your deployed queries | Each deployed query is a separate tool that takes variables by name. |
The first three tools need the schema shared. query works unless the project’s passthrough is none. MCP server lists every tool and the conditions for each.
Make a change#
The project’s MCP endpoint inspects and queries data but never mutates your schema or deploys query files, keeping deploys explicit in your terminal.
The agent reads the schema and writes a query
The agent edits
dbschema/default.geland the files indbschema/querieslike any other code and callscheck_queryon each statement before saving.You deploy
The project’s MCP server cannot change a schema or deploy a query. Schema pushes and deploys are CLI commands that run as you. Either you or the agent runs three commands in your terminal.
Your terminalnapalm schema push notes # the schema, migratednapalm queries push notes # the queries, deployed by namenapalm generate --lang ts # a typed call for each queryThe agent tries the new query
A deployed query shows up as a tool on the agent’s next
tools/list. With a key that may write, the agent can sendis_dry_runto preview a change. A dry run keeps nothing.
Give the agent a branch#
To let an agent test mutations freely, create an isolated branch cloned with --data and issue a branch-scoped key so main stays completely out of the agent’s reach.
Isolated --data branch and branch-scoped key
napalm branches create --data forks schema and rows at /branches/agent-work, pairing with a --branch key that cannot read or mutate main and disappears when the branch is deleted.
napalm branches create notes agent-work --datanapalm keys create notes --label coding-agent --branch agent-work # Point the bridge at the branch for this shell.export NAPALM_KEY=ndb_…export NAPALM_PROJECT_URL=https://notes.napalmdata.com/branches/agent-workA saved key always belongs to main, so pass a branch key through the environment. Because branches do not host deployed queries, the agent sends ad-hoc statements on the branch. Delete the branch after merging, and its key is revoked automatically.
Check the connection#
curl https://notes.napalmdata.com/mcp \ -H "Authorization: Bearer $NAPALM_KEY" \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "tools/list" }'The answer lists query, describe_schema, check_query and the other tools, then your deployed queries. Next, ask the agent about your schema. The agent should call describe_schema and answer from your own types.