Skip to the page

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 none locks agents strictly to your offered list.
Dry-run previews
Every mutating query accepts is_dry_run: true so 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:

dbschema/queries/archiveNote.edgeql
# 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:

Offered MCP tool definition
{  "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 as deployed_query.
Title
Formats the query name as plain words, so archiveNote becomes “Archive note”.
Description
Combines the first comment line in the .edgeql file with runtime execution and dry-run guidance.
Inputs
Requires the query’s typed $variables by 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: true to 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_run because 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: false only 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:

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-only

Passthrough settings and credential scope combine to determine the exact tool list returned to each caller:

SettingOffered to an agent
Passthrough all, schema sharedOffered deployed queries and actions, ad-hoc queries, hybrid search, /ask questions and schema inspection.
Passthrough all, schema hiddenOffered deployed queries and actions, ad-hoc queries and hybrid search. Schema tools and /ask are omitted.
Passthrough keysService keys receive the all toolset, while user-consented agents receive only offered deployed queries and actions.
Passthrough noneOffered 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 grantThe 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>$note parameter accepts only a UUID, whereas a free-form <str>$filter invites 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#

Your terminal
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.

Type a word or two to search every docs page.