---
title: Agent database tools
description: What the Railway Agent and the Railway MCP server can do to a database, which actions need your approval, and when a backup is taken first.
---
The [Railway Agent](/ai/railway-agent) and the [Railway MCP server](/ai/mcp-server) share one set of database tools. An agent uses them to inspect a database, turn high availability, point-in-time recovery (PITR), and PgBouncer on or off, back up and restore, reset a password, and manage PostgreSQL extensions, indexes, and major version upgrades.

Railway checks every call on the server: your role on the project, the approval a change needs, and two-factor authentication where it applies. The checks don't depend on the agent's prompt, so an agent can't skip them.

## Where the tools are available

The same tools are available in three places:

- The Railway Agent in the dashboard. It works on the environment its chat is open in. To change a database in another environment, open the chat there.
- The MCP server at `mcp.railway.com`, through the CLI connection or OAuth. See [Railway MCP Server](/ai/mcp-server) to connect a client.
- [Cloud agents](/cloud-agents).

The database tools aren't available on <a href="https://dev.new" target="_blank">dev.new</a>.

## Supported databases

The tools work on databases deployed from Railway's [database templates](/databases): PostgreSQL, MySQL, Redis, and MongoDB, standalone or as a high availability cluster. A cluster counts as one database. An agent can name any of its services, and the tools find the cluster and act on its primary.

For a service that runs any other image, the describe, audit, and feature tools answer that it isn't an official Railway database. The backup tools work on any service with a volume.

## What an agent can do

Each capability maps to one or more tools. The tool names are what an MCP client lists.

| Capability | Engines | Tools |
| --- | --- | --- |
| Describe a database, or list an environment's databases | PostgreSQL, MySQL, Redis, MongoDB | `describe-database` |
| Read the engine's own statistics | PostgreSQL, MySQL, Redis, MongoDB | `get-database-stats` |
| Audit health, with findings and suggested fixes | PostgreSQL, MySQL, Redis, MongoDB | `audit-database` |
| Turn high availability on or off | PostgreSQL, MySQL, Redis, MongoDB | `enable-database-feature`, `disable-database-feature` |
| Turn point-in-time recovery on or off | PostgreSQL, MySQL | `enable-database-feature`, `disable-database-feature` |
| Add or remove PgBouncer | PostgreSQL | `enable-database-feature`, `disable-database-feature` |
| Create, list, restore, and delete backups, and set backup schedules | Any service with a volume | `create-service-backup`, `list-service-backups`, `restore-service-backup`, `delete-service-backup`, `update-service-backup-schedule` |
| Restore to a point in time | PostgreSQL, MySQL | `restore-database-to-time` |
| Reset the password | PostgreSQL, MySQL, Redis, MongoDB | `reset-database-password`, `get-database-password-rotation-progress` |
| List, install, update, and uninstall extensions | PostgreSQL | `list-database-extensions`, `install-database-extension`, `update-database-extension`, `uninstall-database-extension` |
| List, create, and drop indexes | PostgreSQL | `list-database-indexes`, `create-database-index`, `drop-database-index` |
| Upgrade the major version, follow the upgrade, and revert it | PostgreSQL | `upgrade-database-major-version`, `get-database-upgrade-status`, `revert-database-major-upgrade` |

None of these tools runs SQL that you or the agent write.

### Inspect a database

Three read-only tools answer how a database is doing.

- `describe-database` reports the engine, whether the database is standalone or a cluster with its nodes and primary, PgBouncer, point-in-time recovery, the volume and its backup schedules, and the current load: CPU and memory against their limits, network, disk used, and the engine's own numbers such as connections, cache hit rate, locks, and slow statements. It never returns credentials. Called without a service, it lists the environment's databases and what is staged there.
- `get-database-stats` returns the numbers shown on the database's **Stats** tab.
- `audit-database` checks connections, locks, cache, indexes, slow statements, replication, memory, and disk. Each finding has a severity (critical, warning, or info), the evidence, and a suggested fix. The audit changes nothing.

On a Railway database, an audit fix that needs a server setting is informational. Changing a setting by hand takes the database out of the [support scope](/databases#database-support-scope).

### Create a database with its features

An agent creates a database by deploying its template, such as `postgres-ha` for a PostgreSQL cluster. When the template is staged, PgBouncer, point-in-time recovery, and backup schedules can be turned on while the database is still staged. The whole setup then goes out in one deploy, so you approve once.

Point-in-time recovery on a staged MySQL cluster is the exception. Deploy the cluster first, then turn it on.

```text
Deploy a PostgreSQL high availability cluster with PgBouncer,
point-in-time recovery, and daily backups
```

### Change high availability, PITR, and PgBouncer

Most feature changes are [staged](/deployments/staged-changes): nothing changes until the staged changes are deployed. Point-in-time recovery on a deployed cluster is different. It rolls out as soon as you approve it, one member at a time.

| Change | How it's applied | What to expect |
| --- | --- | --- |
| Turn on high availability | Staged | The database is converted in place into a cluster. Its private hostname changes, and a public TCP address moves to the cluster's proxy on a new host and port |
| Revert high availability | Staged | Variables that point at the cluster are pointed back at the database |
| Add PgBouncer | Staged | PgBouncer is added in front of the database or cluster |
| Remove PgBouncer | Approval, then staged | Variables that point at PgBouncer are updated to connect to PostgreSQL directly, or to the cluster's proxy |
| Turn on PITR, standalone database | Staged | Requires the Pro plan |
| Turn off PITR, standalone database | Approval, then staged | Once deployed, the archive is deleted |
| Turn PITR on or off, cluster | Approval, then rolled out at once | Each member restarts in turn and the primary switches over once. Turning it on requires the Pro plan. Turning it off keeps the archive |

When converting to high availability, an agent can set the number of replicas to one of the counts the template offers.

See the high availability pages for [PostgreSQL](/databases/postgresql-ha), [MySQL](/databases/mysql-ha), [Redis](/databases/redis-ha), and [MongoDB](/databases/mongo-ha), and the [point-in-time recovery](/volumes/point-in-time-recovery) and [PgBouncer](/databases/postgresql-pgbouncer) pages for what each feature does once it's on.

### Back up and restore

The backup tools act on a service's volume. On a cluster, that's the volume of the primary, which after a failover is the promoted replica's.

- **Back up now.** The service keeps running while the [backup](/volumes/backups) is taken.
- **Set schedules.** The schedules become exactly the daily, weekly, and monthly ones you name. A schedule you leave out is removed, and existing backups are kept until they expire.
- **Restore a backup.** Railway copies the backup into a new volume and stages the swap. The current volume is kept. Once deployed, anything written after the backup is no longer served. On a cluster, every database node gets the backup and the coordinators, such as etcd, start from an empty volume.
- **Restore to a point in time.** The restore lands in a new service in the same environment, and the original keeps running unchanged. Point-in-time recovery must already be on. A target earlier than the archive's first completed backup is refused, and the refusal names the earliest time that can be restored.
- **Delete a backup.** The backup is gone for good and can't be restored afterwards.

### Reset a password

`reset-database-password` runs the same reset as **Regenerate** in the [database view](/databases/database-view#connection). The current password stops working, and anything that holds a copy of it, such as an external application or a script, loses access.

On a standalone database, the database and every running service that references the password are redeployed. On a cluster, each member takes the new password in turn, the variables are updated, the cluster's proxies are redeployed one at a time, and the services that use the database are then redeployed together. A cluster rotation takes a few minutes, and `get-database-password-rotation-progress` reports its progress.

A client connected with OAuth doesn't receive the new password. Read it from the service's variables in the dashboard.

### Manage PostgreSQL extensions and indexes

The extension tools cover the extensions the database's image offers.

- Installing an extension also installs the extensions it requires. It runs without asking, because it only adds to the database.
- Updating brings an installed extension to the version the image ships.
- Uninstalling is refused while other extensions, tables, or other objects still depend on the extension. The refusal names them.
- Extensions that Railway manages can't be updated or uninstalled this way.

The index tools build and drop indexes without blocking writes (`CREATE INDEX CONCURRENTLY` and `DROP INDEX CONCURRENTLY`).

- Creating an index runs without asking. The tool waits up to 20 seconds. A longer build carries on in the database, and listing the indexes shows its progress.
- Partitioned tables, unknown columns, and operator classes the database doesn't have are refused.
- Dropping an index that enforces a constraint (primary key, unique, or exclusion) is refused.

### Upgrade a PostgreSQL major version

`upgrade-database-major-version` upgrades a database in place, and a cluster upgrades as a unit. Railway first checks for anything that blocks the upgrade. The database is then stopped, backed up, and upgraded. A standalone database is unavailable for the whole run, and a cluster takes no writes.

The upgrade runs in the background. `get-database-upgrade-status` reports the phase, any error, each member's status, and until when the upgrade can be reverted. Railway keeps that status for 30 days after the run ends.

`revert-database-major-upgrade` restores the pre-upgrade backup while that backup exists. Everything written since the upgrade is discarded. See [Upgrading PostgreSQL major versions](/databases/postgresql-major-upgrade) for the preflight checks and prerequisites.

## Approval

Some changes need a person's approval before they run. Railway builds the question on the server from the call's arguments, so it names the database, the environment, and the consequence.

### What needs approval

These actions ask before they run. The examples use a database named Postgres in an environment named production.

| Action | Question | Shown under the question |
| --- | --- | --- |
| Deploy staged changes over MCP | Deploy the staged changes to my-project / production? | What the deploy adds, removes, and changes, then "Can't be undone from here." Services the deploy removes are named |
| Turn PITR on or off on a cluster | Turn on point-in-time recovery for Postgres in production? | Each member restarts in turn and the primary switches over once. |
| Turn PITR off on a standalone database | Turn off point-in-time recovery for Postgres in production? | Once deployed, its archive is deleted and it can't be restored to a point in time. |
| Remove PgBouncer | Remove PgBouncer from Postgres in production? | Variables that point at PgBouncer are updated to connect to Postgres directly. Connection strings written by hand must be updated. |
| Change backup schedules | Back up Postgres in production daily and weekly? | When the change removes a schedule: "This removes the monthly schedule; existing backups are kept." |
| Stop scheduled backups | Stop scheduled backups of Postgres in production? | Existing backups are kept until they expire. |
| Delete a backup | Delete the backup of Postgres in production from Nov 25, 09:25 UTC? | It can't be restored after this. |
| Reset a password | Reset the password of Postgres in production? | The old password stops working; the database and services using it redeploy. |
| Update an extension | Update the extension vector on Postgres in production from 0.7.0 to 0.8.0? | Nothing |
| Uninstall an extension | Uninstall the extension vector from Postgres in production? | Queries and application code that call its functions stop working. |
| Drop an index | Drop the index orders_created_at_idx on orders in Postgres in production? | Queries that use it get slower, with the number of times the index was scanned |
| Upgrade a major version | Upgrade Postgres in production from PostgreSQL 16 to 17? | The database is unavailable during the upgrade, which can take hours. |
| Revert a major version upgrade | Revert Postgres in production to PostgreSQL 16? | Writes since the upgrade are lost, and the database is down meanwhile. |

On a cluster, some of these describe the cluster instead:

- Removing PgBouncer: "Variables that point at PgBouncer are updated to connect to the cluster's proxy."
- Resetting a password: "The old password stops working; services using it all redeploy at once."
- Upgrading: "The cluster can't take writes during the upgrade, which can take hours." Reverting: "Writes since the upgrade are lost, and the cluster can't take writes meanwhile."

In the dashboard and from an MCP client, these run without a question:

- Describing, auditing, and reading statistics, backups, extensions, and indexes
- Creating a backup
- Creating an index and installing an extension
- Restoring to a point in time, which lands in a new service
- Staging a change, including a backup restore (the approval comes when the staged changes are deployed)

### Approve in the dashboard

The Railway Agent shows an approval card in the chat. The card states the action and its consequence in one or two sentences:

```text
The agent proposes to reset the password of service "Postgres". The old
password stops working and services using it redeploy.
```

Click **Approve** to run the change or **Decline** to stop it.

Staged changes aren't deployed by the Railway Agent in the dashboard. Review and deploy them from the [staged changes](/deployments/staged-changes) banner.

### Approve from an MCP client

The MCP server pauses the call and sends the question to your client, which shows it with its own confirm and decline controls. The call runs only after you confirm. For the database tools, an approval covers the exact arguments it was asked about, works once, and expires after 10 minutes.

The server can only ask a client that declares elicitation support on each request (MCP revision `2026-07-28` and later). Other clients aren't asked by the server. For them, the call depends on the client's own tool permission prompt, and the tools that take something away carry the protocol's destructive hint. `delete-service-backup` is stricter: it's refused when the client can't show the question.

A cloud agent that has no way to put the question to a person is refused. For an automation, the [Railway access](/ai/automations#railway-access) setting can also make changes outside this table wait for approval.

Staged changes are deployed with `accept-deploy`, which asks the question in the table above. If the staged changes are modified after you approve, nothing is deployed and the agent has to ask again.

## Backups taken before a change

Railway starts a backup of the database's volume before a change that touches what runs on that volume.

| Change | Backup taken first |
| --- | --- |
| Turn high availability on or off | Yes, named "Before turning on high availability" or "Before turning off high availability" |
| Turn point-in-time recovery on or off | Yes, named "Before turning on point-in-time recovery" or "Before turning off point-in-time recovery" |
| Add or remove PgBouncer | No. PgBouncer is a service in front of the database and writes nothing to its volume |
| Upgrade a major version | Yes. The database is stopped, backed up, and then upgraded. A revert restores this backup |
| Restore a backup | No backup is taken, but the current volume is kept |
| Restore to a point in time | No. The original database isn't touched |
| Reset a password, change extensions or indexes, change backup schedules, delete a backup | No |

The backups taken before a high availability or point-in-time recovery change don't require the Pro plan. They count toward the plan's backup limit and expire on their own after 21 days. If the database has no volume, there would be no way back, so the change is refused.

A database that is staged and not deployed yet holds no data, so no backup is taken for it.

## Two-factor authentication

In the dashboard, approving a card for one of these actions takes the dashboard's two-factor check when your account has [two-factor authentication](/access/multi-factor-authentication) enabled:

- Deleting a backup
- Dropping an index
- Uninstalling an extension
- Resetting a password
- Upgrading a major version, or reverting the upgrade

Over MCP, a token can't carry a two-factor code. If your account has two-factor authentication enabled, two actions are refused there and must be done in the dashboard:

- Deleting a backup. Delete it from the service's **Backups** tab.
- Deploying staged changes that delete a service, a volume, or a bucket. Reverting high availability, removing PgBouncer, and turning point-in-time recovery off on a standalone database all stage a deletion.

## Roles and plans

The tools apply the role you hold on the project.

| Role | Actions |
| --- | --- |
| Viewer | Describe a database, follow a password rotation, and follow a major version upgrade |
| Member | Everything else, except the admin actions |
| Admin | Delete a backup, upgrade a major version, and revert the upgrade. Deploying staged changes that delete something with `accept-deploy` also needs the admin role |

The tools themselves aren't tied to a plan. These features are:

- Turning on point-in-time recovery requires the Pro plan.
- Manual backups and backup schedules require the Pro plan.

Railway Agent usage is billed as described in [Railway Agent pricing](/ai/railway-agent#pricing).

## Limits and refusals

A refusal comes with its reason and, where there is one, the way forward. These are the refusals you're most likely to see.

- **Rate limit.** The MCP server limits how many tool calls each user can make per hour, across all tools. A call over the limit is refused with the number of seconds to wait.
- **A major version upgrade is running.** A password reset is refused until the upgrade finishes. So are deploys and restarts of the database's services, and deploying staged changes for them.
- **A password reset is already running.** A second reset of the same database is refused until the first one finishes.
- **A PITR rollout is already running on the cluster.** A second one is refused. No tool cancels a rollout. The database's **Backups** tab shows its progress and can cancel it.
- **A PITR change is staged.** Deploy or discard it before you change high availability, PgBouncer, or point-in-time recovery on that database again.
- **A high availability or PgBouncer change is staged or still being applied.** A second one on the same database is refused until the first is deployed, discarded, or finished. PgBouncer staged on top of a staged high availability conversion is the exception.
- **PgBouncer is in front of the database.** Remove PgBouncer before converting to high availability.
- **The database's image was changed to one Railway doesn't publish.** A database that still has point-in-time recovery on is recognized, but features can only be turned off on it.
- **The plan's backup limit is reached.** A new manual backup is refused. Delete an older backup to make room.
- **The backup belongs to a node that is no longer the primary.** After a failover, a backup of the former primary's volume can be deleted but not restored.
- **The upgrade can't be reverted any more.** A revert is refused once the pre-upgrade backup is deleted or expired.