Guides · Agents & copilots
Tools for agents
Every deployed query can serve as an agent tool. Choose which queries to expose and write clear descriptions so agents pick the right tool.
- In the schema
- —
What you’ll build#
You will curate an agent’s tool surface directly from queries your project already deploys across three guarantees.
- Each query is a tool
- Every tool carries a name, model-facing guidance, typed inputs and a verified JSON output schema.
- Curated tool surface
- Sensitive queries stay reserved for your app alone, and
--passthrough nonelocks agents strictly to your offered list. - Dry-run previews
- Every mutating query accepts
is_dry_run: trueso agents can inspect before-and-after diffs prior to committing.
Before you start#
You need a project with deployed queries. You maintain no separate wrapper layer for agents: MCP and A2A expose the exact deployed queries your application invokes by name.
Offer a deployed query as a tool#
Every agent connected to your project receives each offered deployed query under its filename, with no separate tool wrapper or hand-written JSON Schema to maintain.
Queries as typed tools
Compiled queries become named tools with typed inputs and verified output schemas.
Write a standard .edgeql file with an opening comment that tells the model when to call the query:
# Archive one of the caller's notes when the user marks the note finished.update Notefilter .id = <uuid>$note and .author.identity = global callerset { is_archived := true }Deploying archiveNote.edgeql publishes this tool definition on /mcp and the matching skill on /a2a:
{ "name": "archiveNote", "title": "Archive note", "description": "Archive one of the caller’s notes when the user marks the note finished. The project's deployed query archiveNote, run as this connection's identity under the access rules: a call sends only its variables. It makes a change. Send is_dry_run: true to see what it would change, each object before and after, with nothing kept.", "inputSchema": { "type": "object", "required": ["variables"], "additionalProperties": false, "properties": { "variables": { "type": "object", "required": ["note"], "additionalProperties": false, "properties": { "note": { "type": "string", "format": "uuid" } } }, "is_dry_run": { "type": "boolean" } } }, "outputSchema": { … }, "annotations": { "readOnlyHint": false, "destructiveHint": true, "idempotentHint": false, "openWorldHint": false }}Napalm derives every field of that definition directly from the compiled statement:
- Name
- Matches the query filename. If a filename collides with a built-in tool such as
query, Napalm prefixes the name asdeployed_query. - Title
- Formats the query name as plain words, so
archiveNotebecomes “Archive note”. - Description
- Combines the first comment line in the
.edgeqlfile with runtime execution and dry-run guidance. - Inputs
- Requires the query’s typed
$variablesby name and rejects unknown properties. - Output schema
- Reflects the exact selection shape of the compiled query as JSON Schema.
- Dry run
- Mutating queries accept
is_dry_run: trueto return before-and-after row diffs inside a rolled-back transaction.
Every tool executes as the connected caller under your schema’s access policies. Compiled policies on Note enforce isolation, while a query’s own filter clause narrows intent rather than replacing access control.
Offer an action as a tool#
A deployed query with an attached HTTPS handler is an action, and agents receive each offered action as a tool too. The gatekeeper query selects permitted rows before your handler ever runs to perform external work such as sending an email or charging a card.
- Output schema
- Reflects your handler’s return payload when you declare an answer schema on the action.
- No dry run
- Actions omit
is_dry_runbecause external side effects cannot roll back. Gate side effects inside the query, since zero matching rows skip the handler. - Read-only callers
- Read-only keys and grants omit mutating actions. Set
isWrite: falseonly when your handler performs zero writes.
Curate the tool list#
You control which tools appear on /mcp and /a2a independently of the deployed queries your own application invokes at POST /query/{name}.
Curated tool surfaces
Endpoint modes, query flags and read-only keys filter the tools agents see.
Hide sensitive queries with --no-agents, disable ad-hoc passthrough tools or issue a --read-only key from your terminal:
# Hide a deployed query from /mcp and /a2a while keeping POST /query/purgeAccount active.napalm queries offer notes purgeAccount --no-agents # Restrict agents to offered deployed queries and actions only.napalm endpoint notes --passthrough none # Issue a read-only key that excludes all mutating tools.napalm keys create notes --label reader --read-onlyPassthrough settings and credential scope combine to determine the exact tool list returned to each caller:
| Setting | Offered to an agent |
|---|---|
Passthrough all, schema shared | Offered deployed queries and actions, ad-hoc queries, hybrid search, /ask questions and schema inspection. |
Passthrough all, schema hidden | Offered deployed queries and actions, ad-hoc queries and hybrid search. Schema tools and /ask are omitted. |
Passthrough keys | Service keys receive the all toolset, while user-consented agents receive only offered deployed queries and actions. |
Passthrough none | Offered deployed queries and actions for every caller. Ad-hoc queries, search, /ask, schema tools, reach counts and change-log reads are omitted. |
| Read-only key or grant | The tools permitted by the caller’s passthrough mode, minus every mutating query and action. |
An agent calling a hidden query by name receives 403 forbidden, while your application continues calling that query at POST /query/{name}.
Design agent-friendly queries#
Well-shaped deployed queries narrow an agent’s choices to typed IDs and single-purpose steps.
- Single-purpose queries
- Models invoke focused tools more reliably than a broad query controlled by mode flags.
- Document when to call
- The opening comment line becomes the tool description. State what the query changes and when an agent should pick it.
- Prefer typed IDs
- A
<uuid>$noteparameter accepts only a UUID, whereas a free-form<str>$filterinvites malformed inputs. - Return next-step IDs
- Select the identifiers and status fields an agent needs to pass into follow-up tools.
- Prefer deployed queries
- Deployed queries carry compile-time type guarantees and predictable plans, unlike ad-hoc statements drafted at runtime.
Check the tool list#
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 your offered queries and descriptions. Repeat the call with a --read-only key to confirm that mutating tools disappear, then run napalm queries offer with --no-agents to confirm that hidden queries drop from both lists.