Docs / AI agents (MCP)

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.

ServerWhere it runsWhat it can do
Remotehttps://safegrd.dev/mcpReads 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.
Localsafegrd mcp, on the hostStatus, list, doctor, back up, verify, restore into a new or empty target, and export.
Your AI agent can use two MCP servers. The remote server at safegrd.dev/mcp reads your organization's hosts, surfaces, snapshots and drills, and asks for a backup or a Fire Drill. It holds no backup data. The local server, safegrd mcp on your host, backs up, verifies and restores with that host's config and key, against your database and bucket. A request made through the remote server runs on the host at its next check-in, or on SafeGrd for a surface SafeGrd backs up. No tool deletes a snapshot, changes where backups are stored, rotates a key, or changes billing or members. Your AI agent Claude, ChatGPT, Cursor, Codex safegrd.dev/mcp remote: reads state, asks for a backup or drill safegrd mcp local, on your host: backs up, verifies, restores SafeGrd records, no backup data Your host database, bucket, key a request runs at the host's next check-in No tool deletes a snapshot, changes storage, rotates a key, or changes billing or members.
The remote server reads state and asks for work. The local server does the work on your host, with that host's key. A request through the remote server runs at the host's next check-in, or on SafeGrd for a surface SafeGrd backs up.

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

  1. Open Customize, then Connectors, and choose Add, then Add custom connector.
  2. Enter SafeGrd as the name and https://safegrd.dev/mcp as the URL. Choose Continue.
  3. Keep the sign-in settings Claude finds, choose Sign in now, then Add.
  4. Sign in to SafeGrd on the page that opens and approve the connection, as described below.
  5. 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

  1. Open chatgpt.com/plugins, choose +, then Add custom MCP server.
  2. Enter SafeGrd as the name. Under Connection, choose the public endpoint and enter https://safegrd.dev/mcp.
  3. Set the authentication to OAuth, accept the warning about custom servers, and choose Create as a plugin.
  4. Install the plugin. When ChatGPT opens SafeGrd, sign in and approve the connection.
  5. In a new chat, type @ and choose SafeGrd.

Claude Code

  1. Add the server with no header:
    claude mcp add --transport http safegrd https://safegrd.dev/mcp
  2. Restart Claude Code. A session that was already open lists the server only after a restart (claude --continue keeps the conversation).
  3. 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.

ToolArgumentsWhat it does
list_organizationsOrganizations the token belongs to, with plan and quotas.
list_projectsorg_idAn organization's projects, such as production and staging.
list_surfacesproject_id, limit, cursor (all optional)Databases, file trees, mailboxes and hosts, with last backup, drill and alert state.
get_surfacenode_idOne surface or host.
list_snapshotsnode_id; limit, cursor (optional)A surface's snapshots, newest first: when, how big, locked until when, and whether a drill verified them.
get_snapshotsnapshot_idOne snapshot's recorded metadata: digests, counts, lock, Threat Shield verdict.
list_drillsnode_id; limit, cursor (optional)A surface's Fire Drill reports, newest first, with their assertions and signatures.
request_backupnode_idAsk for a backup now. Refused within an hour of the last backup, because each one is locked and stored until it expires.
request_drillnode_idAsk for a Fire Drill of the latest snapshot now. Counted against the plan's drill cadence.
get_storage_usageorg_idHosted storage: whether it is offered, the quota and how much is locked.
get_drill_statsorg_idFire 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:

ToolArgumentsRuns
listsafegrd list
doctorsafegrd doctor
backupsurface or files (optional)safegrd backup --surface for one surface of the host's config, --files for a directory tree, or the configured database
verifysnapshot_id, sandbox_url (optional)safegrd verify --in-memory, or a full drill into an empty database
restoresnapshot_id, and target_dir or target_urlsafegrd restore into an empty target
exportto_dir, or to_bucket and to_endpointsafegrd 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.