AI agents (MCP)
Your coding agent can check your backups over the Model Context Protocol (MCP), take a backup before a risky migration and run a drill to show it restores. Nobody has to open the console.
SafeGrd has two MCP servers. The remote one reads every host's state and asks for a backup or a drill. It never holds data or decrypts anything. The local one runs on a host and backs up, verifies and restores with that host's config and key.
Both servers come with every plan, including the free plan. A tool can ask only for what your plan allows. On the free plan, a Fire Drill runs in memory, once a week.
| Server | Where it runs | What it can do |
|---|---|---|
| Remote | https://safegrd.dev/mcp | Reads organizations, projects, surfaces, snapshots and drills. Asks for a backup or a Fire Drill now. Reads storage use and drill statistics. Gives you the link or the commands that add a surface or a host. |
| Local | safegrd mcp, on the host | Status, list, doctor, back up, verify, restore into a new or empty target, and export. |
What an agent cannot do
No tool deletes a snapshot, changes where backups are stored, rotates a key, or changes billing or members. The server refuses these to a personal access token on every API route, so a token cannot do them through REST either. Nobody can delete a snapshot under compliance-mode Object Lock before its lock expires.
Every tool is marked non-destructive in its MCP annotations, and the read tools are marked read-only, so a client can run them without asking you each time. To take a snapshot before an agent runs a command that could damage the database, use the Agent guard.
The console's Tokens page lists every request_backup and request_drill, along with the same requests made from the console. Each row names the person, the token's name, whether the request came over MCP, and whether it was accepted. A sign-in from claude.ai or ChatGPT is a personal access token with the client's name on it, so the same refusals apply to it.
Add a database from a chat
Ask the agent to back up a database SafeGrd does not back up yet. It gives you a console link that opens Back up on SafeGrd on the right project. For Supabase, DigitalOcean and Heroku, you sign in to the platform on that page and pick the database, so you type no password. For any other database, paste its connection string on that page. Do not paste it into the chat. When you choose Add, SafeGrd takes the first backup and runs a Fire Drill on it, and the agent can see the new surface.
For a database on a machine you run, the agent gives you the commands instead: the installer,
safegrd login, safegrd enroll and the first backup. An agent with a
shell on that machine, such as Claude Code, can run them itself. You approve the sign-in in a
browser.
The remote server
Sign in from Claude or ChatGPT
Add https://safegrd.dev/mcp to your client as a connector. The client opens
SafeGrd, you sign in and approve the connection, and the agent can use SafeGrd. There is no
token to copy.
claude.ai and Claude Desktop
- Open Customize, then Connectors, and choose Add, then Add custom connector.
- Enter
SafeGrdas the name andhttps://safegrd.dev/mcpas the URL. Choose Continue. - Keep the sign-in settings Claude finds, choose Sign in now, then Add.
- Sign in to SafeGrd on the page that opens and approve the connection, as described below.
- In a chat, choose +, then Connectors, and turn on SafeGrd.
On a Team or Enterprise plan, an owner adds the connector once under Organization settings, Connectors, with the same name and URL. Each member then chooses Connect next to SafeGrd under Customize, Connectors, and signs in to SafeGrd as themselves. A connector you add on claude.ai also shows up in Claude Desktop.
ChatGPT
- Open chatgpt.com/plugins, choose +, then Add custom MCP server.
- Enter
SafeGrdas the name. Under Connection, choose the public endpoint and enterhttps://safegrd.dev/mcp. - Set the authentication to OAuth, accept the warning about custom servers, and choose Create as a plugin.
- Install the plugin. When ChatGPT opens SafeGrd, sign in and approve the connection.
- In a new chat, type
@and choose SafeGrd.
Claude Code
- Add the server with no header:
claude mcp add --transport http safegrd https://safegrd.dev/mcp - Restart Claude Code. A session that was already open lists the server only after a
restart (
claude --continuekeeps the conversation). - In Claude Code, run
/mcp, choose safegrd, then Authenticate. Your browser opens SafeGrd. Sign in and approve the connection.
You can install the Claude Code plugin instead. It adds the same server, signed in the same
way, plus skills that back up and run a Fire Drill before a risky change and report on
backup health. After installing, run /mcp and choose Authenticate as
above. The source is at safegrd/agent-plugins.
/plugin marketplace add safegrd/agent-plugins
/plugin install safegrd@safegrd
When you sign in, SafeGrd's Connect an agent page shows the name the client gave itself and the address it will send you back to. If that is not the app you are connecting, choose Deny. Otherwise, pick the organization the agent may reach, limit it to one project if you want, and choose Approve.
Approving creates an access token, named after the client, under Tokens in the console. Revoke it there and the agent loses access on its next call. The client's token lasts an hour and renews itself. It works on the MCP server only, and the REST API refuses it.
The sign-in is OAuth 2.1 with PKCE. A client reads the server's metadata at
/.well-known/oauth-authorization-server. It then either registers itself or
SafeGrd reads its client metadata document.
Or a personal access token
For a client that cannot sign in, such as CI, a script or Cursor, create a personal access token in the console under Tokens and send it as a bearer header. In Claude Code:
claude mcp add --transport http safegrd https://safegrd.dev/mcp \
--header "Authorization: Bearer sg_pat_..."
Any client that supports the Streamable HTTP transport and a bearer header works the same way. The server keeps no session and checks every call against the token as it is now. If you revoke the token in the console, the agent stops on its next call.
Other clients
In Cursor, add this to ~/.cursor/mcp.json, or to .cursor/mcp.json
in a project:
{
"mcpServers": {
"safegrd": {
"url": "https://safegrd.dev/mcp",
"headers": { "Authorization": "Bearer sg_pat_..." }
}
}
}
In VS Code, add this to .vscode/mcp.json. VS Code asks for the token the
first time it starts the server and stores it, so the file holds no secret:
{
"inputs": [
{ "type": "promptString", "id": "safegrd-token",
"description": "SafeGrd personal access token", "password": true }
],
"servers": {
"safegrd": {
"type": "http",
"url": "https://safegrd.dev/mcp",
"headers": { "Authorization": "Bearer ${input:safegrd-token}" }
}
}
}
Clients that browse the
MCP Registry
can install SafeGrd from there, as dev.safegrd/safegrd. It is also on
Smithery as
safegrd/safegrd. On Smithery, enter the whole header value,
Bearer sg_pat_..., in the x-safegrd-token field.
| Tool | Arguments | What it does |
|---|---|---|
| list_organizations | Organizations the token belongs to, with plan and quotas. | |
| list_projects | org_id | An organization's projects, such as production and staging. |
| list_surfaces | project_id, limit, cursor (all optional) | Databases, file trees, mailboxes and hosts, with last backup, drill and alert state. |
| get_surface | node_id | One surface or host. |
| list_snapshots | node_id; limit, cursor (optional) | A surface's snapshots, newest first: when, how big, locked until when, and whether a drill verified them. |
| get_snapshot | snapshot_id | One snapshot's recorded metadata: digests, counts, lock, Threat Shield verdict. |
| list_drills | node_id; limit, cursor (optional) | A surface's Fire Drill reports, newest first, with their assertions and signatures. |
| request_backup | node_id | Ask for a backup now. Refused within an hour of the last backup, because each one is locked and stored until it expires. |
| request_drill | node_id | Ask for a Fire Drill of the latest snapshot now. Counted against the plan's drill cadence. |
| get_storage_usage | org_id | Hosted storage: whether it is offered, the quota and how much is locked. |
| get_drill_stats | org_id | Fire Drill pass rate and results across an organization. |
The remote server does not run backups or drills itself. On a surface your host backs up, the host's daemon picks up the request at its next check-in. So request_backup and request_drill do nothing unless the daemon is running on that host. A surface set to Back up on SafeGrd or Drill on SafeGrd in the console is queued on SafeGrd instead, and needs no daemon. If the API refuses a request, the tool error carries the API's own words, so the agent can tell you why.
The three list tools return {"items": [...], "next_cursor": "..."}, 25 items at a
time unless you set limit (up to 200). For the next page, pass
next_cursor back as cursor. The last page has no
next_cursor.
The local server
An agent running on the host itself can use safegrd mcp, which serves that
host's SafeGrd over stdio. In Claude Code:
claude mcp add safegrd -- safegrd mcp
If the host runs the CLI as a container, run the same image with the volume you enrolled with, which holds its config and key:
claude mcp add safegrd -- docker run -i --rm \
-v safegrd:/home/safegrd/.safegrd ghcr.io/safegrd/cli mcp
Each tool runs the CLI command of the same name with this host's config, and refuses whatever that command refuses. Two more limits apply:
- No tool takes a private key. The tools use the host's
key_path, so your key never passes through an agent's context. - restore writes only into a new or empty directory, or into a database it has checked is empty. An agent cannot restore over data.
| Tool | Arguments | Runs |
|---|---|---|
| list | safegrd list | |
| doctor | safegrd doctor | |
| backup | surface or files (optional) | safegrd backup --surface for one surface of the host's config, --files for a directory tree, or the configured database |
| verify | snapshot_id, sandbox_url (optional) | safegrd verify --in-memory, or a full drill into an empty database |
| restore | snapshot_id, and target_dir or target_url | safegrd restore into an empty target |
| export | to_dir, or to_bucket and to_endpoint | safegrd export, still encrypted |
The REST API underneath
Every remote tool calls the same /api/v1 routes the console uses.
/openapi.json describes the routes an agent needs, and
/llms.txt points an agent at these docs. You can see the remote
server's tools without a token at /.well-known/mcp/server-card.json.