Safeguards for AI agents with production access: limits the agent can’t argue with.
An instruction in the prompt is not a safeguard; the agent can ignore it. Real limits live outside the model: a token scoped to what the task needs, a database role that can’t write, an approval prompt before deploys, tools that can’t delete, a log of what the agent did, and a staging project it tries everything on first.
Facts checked
Why a code freeze in the prompt didn’t hold
In July 2025 an agent on Replit deleted a live database during an explicit “code and action freeze”. It later said it had ignored the instruction not to proceed without approval, and it first claimed a rollback would not work, which turned out to be wrong. The owner recovered the data by hand.
The lesson is not that one tool is bad. The agent had credentials that could drop the database, and nothing between the model and the database said no. OWASP calls this excessive agency and names three causes: too many tools, too much permission, too little human approval. Each layer below removes one.
| Source | What it says |
|---|---|
| Fortune, 2025-07-23 (Replit incident) † | The agent deleted a live database during a code freeze; Replit then added automatic separation of development and production databases and better rollback |
| OWASP Top 10 for LLM applications, LLM06:2025 † | Excessive agency comes from excessive functionality, permissions and autonomy; grant minimum permissions such as read-only database access, require human approval for high-impact actions, and enforce authorization in the downstream system, not in the LLM |
| MCP specification (2025-06-18), tools † | “There SHOULD always be a human in the loop with the ability to deny tool invocations”; clients MUST treat tool annotations as untrusted unless the server is trusted; clients SHOULD log tool usage |
| Claude Code docs, permissions † | Rules are evaluated deny, then ask, then allow; the first match decides, and a deny in any settings file blocks an allow in another |
† Competitor details come from each vendor’s own published pages on the dates shown; prices and plans change, so check the vendor before you decide. Fortune, 2025-07-23 (Replit incident) (2026-10-29) · OWASP Top 10 for LLM applications, LLM06:2025 (2026-10-29) · MCP specification (2025-06-18), tools (2026-10-29) · Claude Code docs, permissions (2026-10-29)
The six layers
| Layer | What it stops | How you check it |
|---|---|---|
| 1. Scoped, expiring token | An agent doing more than its task, or a leaked token doing anything for long | Call a tool outside the scope; expect a tool error naming the missing scope |
| 2. Read-only database role | DELETE, DROP and UPDATE from a confused query | Run a delete as the role; expect permission denied |
| 3. Approval before writes | A deploy or config change nobody saw coming | The client prompts before each listed tool |
| 4. No destructive tools | Deleting what can’t be undone, even with approval fatigue | List the tools; there is no delete |
| 5. Audit log | Not knowing what happened, or by which credential | Find the token in the log after a test run |
| 6. Staging first | Experiments on real users’ data | The agent’s token and connection string point at staging |
1. A token scoped to the task, with an expiry
Give the agent its own token, never yours. On Canner, a token’s reach is the creating user’s permissions and the token’s own scopes, whichever is narrower, and membership is re-checked on every request: remove the user and their tokens stop working at once (users and tokens).
In Identity → API keys there are two kinds. MCP connector (deploy only) carries projects:write, deployments:write, env:write and domains:write: it can create projects, deploy, add variables and attach domains, but cannot read a variable’s value back, delete a project, read billing, create tokens or touch databases. Full access has no scopes. Either can expire after 30, 90, 180 or 365 days. A full-access token can also be restricted to named projects, but a project-restricted token is refused by the MCP endpoint, so use that one with the CLI or REST API.
For an agent that only diagnoses, mint a read-only token through the API. Scopes are <resource>:read or <resource>:write, and write implies read, with two exceptions that must be named: env:read (variable values) and projects:delete:
# A token that can look but not change anything, valid for 30 days
curl -s -X POST https://api.canner.ca/v1/tokens \
-H "Authorization: Bearer $CANNER_ADMIN_TOKEN" \
-H "content-type: application/json" \
-d '{
"name": "agent-readonly",
"scopes": ["projects:read", "deployments:read", "databases:read"],
"expires_in_days": 30
}'
# What the agent gets back when it tries to deploy with it (MCP):
# Error: this API token lacks the "deployments:write" scope required by canner_deploy.2. A database role that can’t write
An agent that writes SQL to answer questions needs to read, not write. Give it its own login, not the owner’s connection string. A read-only role stops the delete at the database, whatever the model decides.
Don’t rely on default_transaction_read_only = on alone: any session can turn it off again with SET. A grant is a boundary; a session default is a suggestion.
-- Any Postgres 14+: a login that can read every table and write none
CREATE ROLE agent_ro LOGIN PASSWORD 'use-a-generated-one';
GRANT pg_read_all_data TO agent_ro; -- needs superuser, or ADMIN on pg_read_all_data
-- Where you can't grant that, per schema instead:
-- GRANT USAGE ON SCHEMA public TO agent_ro;
-- GRANT SELECT ON ALL TABLES IN SCHEMA public TO agent_ro;
-- ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO agent_ro;
ALTER ROLE agent_ro SET statement_timeout = '15s'; -- no runaway scans
ALTER ROLE agent_ro CONNECTION LIMIT 3;
-- Check: this must fail with "permission denied for table users"
SET ROLE agent_ro;
DELETE FROM users WHERE id = 1;
RESET ROLE;
-- On a Canner dedicated instance, the same in one command:
-- canner db roles <name> create agent --read-only3. An approval step before anything that writes
The MCP spec puts approval on the client: it SHOULD show which tools are exposed and ask before sensitive calls. In Claude Code, that is the permissions block. Rules are evaluated deny, then ask, then allow, and the first match wins, so a deny in any settings file beats an allow in another.
Allow the reads you want to run unattended, ask before deploys and variable changes, and deny shell access to the database outright so the agent can’t route around the role you made. Commit this as .claude/settings.json so the whole team gets it:
{
"permissions": {
"deny": [
"Bash(psql *)",
"Bash(dropdb *)",
"Bash(git push --force *)",
"Read(./.env)",
"Read(./.env.*)"
],
"ask": [
"mcp__canner__canner_deploy",
"mcp__canner__canner_set_env_var",
"mcp__canner__canner_save_app",
"Bash(canner deploy *)"
],
"allow": [
"mcp__canner__canner_list_errors",
"mcp__canner__canner_get_deployment",
"mcp__canner__canner_search_logs"
]
}
}4. Tools that can’t delete
The safest destructive tool is the one that doesn’t exist. Canner’s MCP server deliberately exposes no way to delete a project, revoke a token, or drop a database or domain; those are done from the dashboard or the CLI. Backups are list-only through MCP: taking, restoring and deleting them is a dashboard or CLI action.
The write tools that remain are built to fail safe. canner_copy_database refuses a target that isn’t empty. canner_set_env_var skips a duplicate key instead of overwriting it. canner_get_database hides the password unless the agent passes reveal: true. Restarting a dedicated instance, applying a memory split or turning replication on all require confirm: true, and the tool’s own description tells the agent to ask the owner first.
Be clear about what is left. canner_deploy redeploys, and a production canner_set_env_var takes effect at the next deploy. Every production deploy on Canner stops the old process before starting the new one, a brief interruption. That is why they belong in your ask list.
5. A log of what the agent did
Log at two levels. The client keeps the transcript: which tool, which arguments, what came back. The platform keeps its own record that the agent can’t edit.
Canner’s audit log is append-only and records the actor type on every event: user, token or system. It captures deploys (including rollbacks), environment variable creates, updates, deletes and reveals, sign-ins, and token creation with the token’s scopes and expiry. It is kept 13 months and comes with the Compliance add-on ($29/mo). It does not record every read an agent makes, such as listing logs; for that, keep the client transcript.
6. Staging first, as a separate project
On Canner, pull-request previews share the project’s database: a preview runs the branch’s code against production data. A staging environment for an agent therefore has to be its own project, with its own database and variables (environment variables). Turn previews off on the production project, keep them on in staging, and give the agent the staging project’s connection string.
Before an agent gets write access anywhere, turn on a backup policy and take a backup on demand. Restoring defaults to a new database, and Inspect first lets you compare a restore with the live data before you swap it in.
Questions
Is telling the agent “don’t touch production” enough?
No. A prompt instruction is input the model can misread or ignore, as the Replit incident showed. Put the limit where the model can’t change it: the token’s scopes, the database role’s grants, and the client’s approval rules.
Can an AI agent delete my Canner project through MCP?
No. The Canner MCP server has no tool to delete a project, revoke a token, or drop a database or domain. Those are dashboard or CLI actions. It can still deploy, and a production deploy briefly stops the app while the new version starts.
What token should I paste into Lovable, Bolt or v0?
The MCP connector (deploy only) token type. It can create projects, deploy, set variables and attach domains, but can’t read a variable’s value back, delete a project, read billing, create tokens or reach databases. Give it an expiry.
How do I give an agent read-only database access?
Create a separate login role with read grants only. On any Postgres 14 or later, GRANT pg_read_all_data. On a Canner dedicated instance, canner db roles <name> create agent --read-only. Then test it by running a DELETE as that role.
Do I need an audit log if the agent client keeps a transcript?
Yes, for anything that matters. The transcript lives with the agent and can be lost or edited. A platform audit log is append-only and records which credential acted, which is what you need after an incident.
Let the agent deploy, not delete.
Canner’s MCP server has no delete tools, and its connector tokens can’t touch billing or databases. Start free.