Skip to the page

Feature by feature

Chapter 9 of 11

Agents and copilots

Every project serves MCP and A2A directly. External assistants, in-app copilots and background agents run under your schema’s rules and expiring grants.

When an AI assistant reads user documents, any untrusted sentence inside a record enters the model’s prompt. A tool server holding a shared backend key can be tricked into reading or modifying another user’s rows.

In practice

Every Napalm project serves a built-in MCP endpoint governed by the caller’s schema policies. When Ada connects her AI assistant and approves OAuth access, every tool call runs as Ada rather than a shared service account.

Connector address
https://notes.napalmdata.com/mcp
Even if a prompt asks for every row in the database, PostgreSQL returns only notes Ada is allowed to read.

Built-in MCP and A2A#

Pillar at work: Compiled

Projects serve Streamable HTTP MCP at /mcp and Agent-to-Agent discovery at /a2a straight from your schema with no wrapper server to deploy. Connected agents call deployed queries as typed tools, run hybrid search and invoke actions. Committed writes stream to live clients and appear in the change log tagged with mcp or a2a.

Ada’s assistant
Which of my notes mention the launch checklist, and who else can edit?
search type: "Note", query: "launch checklist"
myNotes
Two notes match: “Launch checklist” (shared with Ben) and “Q4 launch notes” (yours alone). Those cover the notes your account can read.
Deployed queries and hybrid search are exposed automatically as typed MCP tools.

Because OAuth consent binds global caller to the approving user, access policies compile into every SQL statement the agent triggers. Hostile prompt text inside a record cannot widen which rows the agent can read or modify, and read-only consent blocks mutations before execution.

Built-in /mcp and /a2a

Saved queries, search and actions appear as tools under the caller’s policies.

Copilots and dry runs#

Pillar at work: Checked and fault-tested

In-app assistants need no backend service key. Your application forwards the signed-in user’s session token to POST /ask.

Terminal
curl https://notes.napalmdata.com/ask \  -H "Authorization: Bearer $SESSION" \  -H "Content-Type: application/json" \  -d '{ "question": "Which of my notes mention the launch?" }'
Run a natural-language question directly under the signed-in user’s session.

Because EdgeQL has static types and cardinalities without SQL NULLs, Napalm type-checks every generated query against your schema before running a read. When a question asks to modify data, Napalm executes a rolled-back dry run (is_dry_run) and returns a proposal containing the compiled query and before-and-after row diffs for the user to confirm.

Dry-run write previews

Read questions run directly, while writes return rolled-back diffs for approval.

Expiring row grants#

Pillar at work: Caller-bound

Unattended background agents often need narrower access than a user’s full account. Create a dedicated ext::auth::Identity for the agent, which starts with access to zero records, and model a grant type linking that identity to chosen rows and an expiration timestamp.

dbschema/default.gel
type AgentGrant {  required owner: ext::auth::Identity;  required agent: ext::auth::Identity;  multi notes: Note;  required expires: datetime;   access policy owner_manages_grant    allow all    using (.owner ?= global caller);} type Note {  # …workspace, owner, editors, fields, indexes and policies  access policy granted_agent_can_read    allow select    using (exists (      select .<notes[is AgentGrant]      filter .agent ?= global caller        and .expires > datetime_of_statement()    ));}
Grant a background summarization agent read access to chosen notes until an exact timestamp.

Granting select alone prevents writes, and checking .expires > datetime_of_statement() inside the policy enforces the deadline on PostgreSQL’s statement clock with no background cleanup job.

Expiring row grants

Open chosen rows to an agent identity until an exact statement timestamp.

Immediate revocation

Deleting a grant cuts off queries and live streams on the same commit.

Revoking access#

Cutting off an agent before its grant expires takes a single delete.

dbschema/queries/revokeGrant.edgeql
delete AgentGrantfilter .agent.id = <uuid>$agent
Deleting the AgentGrant row drops those notes from any open live stream on the same commit.

Subsequent tool calls from the background agent return zero rows, and users can disconnect OAuth MCP sessions at any time by revoking consent.

That closes the architectural test from Chapter 1: users on web and mobile, backend workers, warehouse syncs, training jobs, in-app copilots and autonomous agents all share one database under access policies written once.

Every caller now shares one schema on a single database. Next, we scale that schema across branches, read replicas and shards while testing real hardware faults.

Type a word or two to search every docs page.