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.
- You choose the list
- Sensitive queries stay reserved for your app alone, and
--passthrough nonelocks agents strictly to your offered list. - Changes can be previewed
- Every mutating query accepts
is_dry_run: true, letting an agent 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 the project receives each offered deployed query under its own name. Napalm synthesizes the tool’s input schema, output schema and dry-run flag directly from the compiled .edgeql file.
Compiled EdgeQL cartridge to typed tool contract
Each dbschema/ file compiles into a named tool with strict JSON variables, a verified outputSchema, first-line comment guidance and is_dry_run mutation previews.
# Archive one of the caller's notes. Use it when they say a note is finished.update Notefilter .id = <uuid>$note and .author.identity = global callerset { is_archived := true }{ "name": "archiveNote", "title": "Archive note", "description": "Archive one of the caller’s notes. Use it when they say a note is 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 }}- Name
- The query’s name. A query named like a built-in tool, such as
query, is offered asdeployed_query. - Title
- The name as words.
archiveNotereads “Archive note”. - Description
- The first line of the file’s opening comment, or the title when the file has no comment, paired with execution metadata.
- Inputs
- The query’s typed
$variables. A call passes those variables by name and nothing else. - Answer
- The shape the query selects, emitted as a JSON schema the agent can rely on.
- Dry run
- Any query that writes also accepts
is_dry_run, returning each object before and after 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.
- Answer
- The handler’s return value. Declare an answer schema to tell the agent what shape to expect.
- No dry run
- External side effects cannot be rolled back, so actions omit
is_dry_run. Gate side effects in the action’s query, because a query matching zero rows never wakes the handler. - Read-only callers
- A read-only key or grant is never offered a mutating action. Mark an action
isWrite: falseonly when its handler performs zero writes.
Choose the tool list#
Endpoint passthrough, --no-agents flags and credential modes let you curate the exact tool surface exposed on /mcp and /a2a without restricting the queries your own application calls at POST /query/{name}.
Curated /mcp and /a2a tool manifold
napalm queries offer --no-agents hides sensitive operations from tools/list and GetExtendedAgentCard, while --read-only credentials automatically drop every mutating tool.
# Keep a query for your app, and off every agent's list.napalm queries offer notes purgeAccount --no-agents # Only your deployed queries: no statements of an agent's own, no search, no questions.napalm endpoint notes --passthrough none # A key that can't be offered a change at all.napalm keys create notes --label reader --read-only| Setting | Offered to an agent |
|---|---|
Passthrough all, schema shared | Your deployed queries, the agent’s own statements, search, questions and the schema. |
Passthrough all, schema hidden | Your deployed queries, the agent’s own statements and search. No schema and no questions in words. |
Passthrough keys | Service keys get the same access as all, while user-consented agents get only deployed queries and actions. |
Passthrough none | Your deployed queries and actions for every caller. No statements, search, questions, schema, reach counts or change log. |
| A read-only key or grant | The tools the rows above allow, minus every tool that writes. |
An agent calling a hidden query by name receives 403 forbidden, while your application continues calling it at POST /query/{name}.
Write clear tools#
Well-shaped deployed queries narrow an agent’s choices to typed IDs and single-purpose steps.
- One job each
- Agents pick a single-purpose tool correctly more often than a tool with a mode to pick.
- Say when to use the tool
- The first comment line becomes the tool description. State clearly what the query does and when to call it.
- Prefer ids to text
- A
<uuid>$notecan only be a note. A<str>$filtergives the agent room for mistakes. - Return the next tool’s inputs
- Select the fields the agent needs for the next step, such as the id for the next tool.
- Prefer a tool to an ad-hoc statement
- A deployed query is checked against your schema and has a known cost. An ad-hoc statement from an agent has neither.
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 answer lists your queries by name, each with a description. Run the request again with a read-only key, and the queries that write are gone. Run napalm queries offer with --no-agents on a query, and the query leaves both lists.