Guides · Agents & copilots
Coding agents
Configure a repository so coding agents inspect your schema, typecheck every new query before saving and keep credentials out of 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.
- Project conventions
- Your repository documents the layout of a Napalm project: schema, deployed queries, access policies and generated client.
- Checked queries
- The agent compiles each candidate EdgeQL statement against your live schema before writing the query file.
- Zero secrets in git
- Committed MCP configs invoke
napalm mcp, reading your key from local CLI config rather than repository files. - Read-only by default
- 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 up the repository#
napalm init configures your editor and coding agent against the project’s MCP server while keeping every service key outside version control.
Local CLI bridge
Editors invoke the local CLI subprocess while service keys stay outside git.
Run three commands from your repository root to generate agent instructions, store a read-only key locally and turn on schema inspection:
# Write agent instructions into AGENTS.md and register the local MCP bridge.napalm init notes # Create a read-only service key and store it in your local CLI config.napalm keys create notes --label coding-agent --read-only --save # Allow the agent to inspect your schema and type-check candidate queries.napalm endpoint notes --share-schemaEach step writes to a distinct location so teammates share project setup without sharing credentials:
- Agent instructions
napalm initwrites a Napalm section intoAGENTS.mdand configuresCLAUDE.mdto importAGENTS.md. Re-runnapalm initafter upgrading the CLI to refresh that section.- MCP config
napalm initalso registersnapalm mcp notesin.mcp.json,.cursor/mcp.jsonand.vscode/mcp.json. Those files contain zero secrets and are safe to commit.- Local service key
--savestores the key in your local CLI config wherenapalm mcpreads it automatically. Each teammate creates an individual key.
Because the generated .mcp.json passes only the project slug to napalm mcp, you can commit the file directly:
{ "mcpServers": { "notes": { "command": "napalm", "args": ["mcp", "notes"] } }}Inspect the MCP 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 | Returns your schema types, links and access policies. |
check_query | Type-checks an EdgeQL statement against the live schema and reports whether the statement reads or writes without executing it. |
explain_query | Returns execution counts and latency for past queries, or the planner estimate for a new statement. |
query | Executes an EdgeQL statement and returns JSON rows. Read-only keys reject writes before execution. |
describe_reach | Counts the rows the active credential can read, update and delete per type. |
read_changes | Reads committed changes since a timestamp or cursor under the active credential’s policies. |
| Deployed queries | Exposes each offered deployed query as a named tool with typed variables. |
The first three tools require --share-schema, and query requires passthrough all or keys. MCP server documents every tool and availability rule.
Edit, check and deploy#
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 edits and type-checks locally
The agent edits
dbschema/default.gelanddbschema/, callingqueries/ *.edgeql check_queryto validate each statement before saving.You push and deploy from the terminal
Review the edited schema and
.edgeqlfiles in git, then push the migration, deploy named queries and regenerate your typed client:Your terminalnapalm schema push notes # apply schema changesnapalm queries push notes # deploy .edgeql files by namenapalm generate --lang ts # generate the typed clientThe agent tests the deployed tool
Each newly deployed query appears on the agent’s next
tools/listcall. Callers with write access can passis_dry_run: trueto preview row diffs inside a rolled-back transaction.
Give the agent a branch#
When an agent needs to test writes or destructive edits, isolate its work on a disposable branch so main stays completely out of the agent’s reach.
Isolated agent branches
Branch keys restrict mutations to a cloned branch and never reach main.
Clone the schema and existing rows with --data, mint a key scoped to that branch and export both environment variables in the shell where your agent starts:
napalm branches create notes agent-work --datanapalm keys create notes --label coding-agent --branch agent-work # Point napalm mcp at the branch in this shell.export NAPALM_KEY=ndb_…export NAPALM_PROJECT_URL=https://notes.napalmdata.com/branches/agent-workSaved CLI keys target main, so branch keys connect through NAPALM_KEY and NAPALM_PROJECT_URL instead. Branches run ad-hoc queries rather than deployed queries, and deleting a branch revokes its keys 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 response lists query, describe_schema, check_query and your deployed queries. Ask your coding agent to summarize the project’s schema and confirm that it calls describe_schema to inspect your types.