open_database_connection #

View this page as Markdown

On this page

Generated automatically from the published contract sources.

A script calls this action over HTTPS at POST https://tzcloud.turnzero.ai/v1/open_database_connection, with a bearer credential and the action's payload as the JSON body. An MCP connection lists this action as the tool tzcloud_open_database_connection.

OAuth access tokens and minted tokens, including the turnzero command's computer token, are bearer credentials. The action determines which kinds, scopes and grants it accepts (Sign-in, sessions, and tokens).

Build metadata: Registered in this build. Registration describes the default dispatcher in this build. It does not guarantee that a caller has the required credential or grant, that a tool is listed for that connection, or that the required service is configured.

Contract description #

Request a one-hour connection to your application's production database for tools such as pg_restore, pg_dump or psql. Call when the owner asks to use a PostgreSQL tool against production. The approved tool can read, change or delete data in that application's production database. Returns 202 with a pending action and a link the account owner opens in a browser to approve the request. A decline or expiry changes nothing. After approval, use the pending action ID in turnzero db connect --grant <id> -- <tool> [args]. A new approval for the same application ends its previous connection.

More about this action #

The application argument identifies your application's production database. Pass request_id to make a repeat safe while its pending action is live. The same account and request_id return that action while it is requested, approved or executing. After it ends, the identifier starts a new request.

The 202 response gives pending_action and approval_url. Give the person the link to approve or decline in a browser. Read read_approval_status with pending_action.id. On completion, the outcome gives application, connection and detail. connection contains its id, the UTC expiry expires_at and the full relay address.

Run turnzero db connect --grant <id> -- <tool> [args] using the pending action's ID for <id>. The command waits for approval and starts the PostgreSQL tool as a child process. The command prints no password. Use tools such as pg_restore to import, pg_dump to export, or psql to connect interactively.

The connection lasts up to an hour from approval. It ends at expires_at, when the command ends the grant, or when a newer approval replaces it. A production database move, a move of the application between cells, or application deletion also ends it. If a platform release cuts the connection short, request a new connection and run the tool again.

An account suspension can also end the connection. If it did, request a new approval after the account is active again.

If opening a replacement fails after the previous grant ends, the previous grant stays ended. Check read_approval_status for the replacement's outcome.

For development, connect directly with the development database credential.

database_not_provisioned means the application has no production database. database_move_in_flight means a production database move or a move of the application between cells is unfinished. Both are 409 responses. With destructive_class_required, reconnect under a credential with the destructive class.

Access and action metadata #

{
  "name": "open_database_connection",
  "resource": "application",
  "tier": "destructive",
  "surface": "tzcloud",
  "addresses": [
    "tzcloud"
  ],
  "product": "cloud",
  "summary": "Request a time-limited connection to your application's production database for standard PostgreSQL tools. Returns 202 with a pending action for browser approval. Approval opens one connection for up to an hour and ends any existing connection for the application. A decline or expiry changes nothing.",
  "annotations": {
    "readOnlyHint": false,
    "destructiveHint": true,
    "openWorldHint": true
  }
}

MCP catalog entry #

{
  "name": "open_database_connection",
  "title": "Open a production database connection",
  "tier": "destructive",
  "scenario": "API-L0-32",
  "summary": "Request a one-hour connection to your application's production database for tools such as `pg_restore`, `pg_dump` or `psql`. Call when the owner asks to use a PostgreSQL tool against production. The approved tool can read, change or delete data in that application's production database. Returns 202 with a pending action and a link the account owner opens in a browser to approve the request. A decline or expiry changes nothing. After approval, use the pending action ID in `turnzero db connect --grant <id> -- <tool> [args]`. A new approval for the same application ends its previous connection.",
  "owners": [
    "API-L0-32"
  ]
}

request #

JSON pointer Description and constraints
"" (root) Type: object
Required fields: ["application"]
/properties/application Your account's application ID from list_applications. The connection is for its production database.

Type: string
/properties/request_id An optional string you choose. While the same account's earlier pending action is requested, approved or executing, repeating this value returns that action. After it ends, the same value starts a new action. Omit this member to create a new request each time.

Type: string

response #

JSON pointer Description and constraints
"" (root) The 202 response with the pending action and its approval link. Read its outcome with read_approval_status. A decline or expiry changes nothing.

Type: object
Required fields: ["contract_version","pending_action","approval_url"]
/properties/contract_version Required value: 1
/properties/reference The short reference the platform recorded your call under: ten lowercase hexadecimal characters, the value in the call’s record row. Quote it when you report the call.

Type: string
Pattern: ^[0-9a-f]{10}$
/properties/pending_action The pending action for browser approval. A completed outcome gives the production database connection. A failed outcome gives the refusal.

/properties/pending_action/allOf/0 $ref: #/shapes/pending_action
/properties/pending_action/allOf/1 Type: object
/properties/pending_action/allOf/1/properties/outcome The outcome of the approved action, with the application, its time-limited production connection and the next step.

Type: ["object","null"]
/properties/pending_action/allOf/1/properties/outcome/properties/application The ID of the application whose production database the connection reaches.

Type: string
/properties/pending_action/allOf/1/properties/outcome/properties/connection The approved production database connection. Use the pending action ID in turnzero db connect --grant <id>, and use expires_at to see when it expires.

Type: object
Required fields: ["id","expires_at","relay"]
/properties/pending_action/allOf/1/properties/outcome/properties/connection/properties/id The ID of the approved database connection.

Type: string
/properties/pending_action/allOf/1/properties/outcome/properties/connection/properties/expires_at The UTC instant when the connection's grant expires, one hour after approval.

Type: string
Format: date-time
/properties/pending_action/allOf/1/properties/outcome/properties/connection/properties/relay The full WebSocket address of the approved connection's relay.

Type: string
/properties/pending_action/allOf/1/properties/outcome/properties/detail Gives the command route and when the connection ends.

Type: string
/properties/approval_url The link the person opens in a browser to approve or decline this request.

Type: string
/properties/detail Explains the browser approval and points to read_approval_status for the outcome.

Type: string

Complete payload contract #

{
  "request": {
    "type": "object",
    "required": [
      "application"
    ],
    "properties": {
      "application": {
        "type": "string",
        "description": "Your account's application ID from `list_applications`. The connection is for its production database."
      },
      "request_id": {
        "type": "string",
        "description": "An optional string you choose. While the same account's earlier pending action is requested, approved or executing, repeating this value returns that action. After it ends, the same value starts a new action. Omit this member to create a new request each time."
      }
    }
  },
  "response": {
    "type": "object",
    "description": "The 202 response with the pending action and its approval link. Read its outcome with `read_approval_status`. A decline or expiry changes nothing.",
    "required": [
      "contract_version",
      "pending_action",
      "approval_url"
    ],
    "properties": {
      "contract_version": {
        "const": 1
      },
      "reference": {
        "type": "string",
        "pattern": "^[0-9a-f]{10}$",
        "description": "The short reference the platform recorded your call under: ten lowercase hexadecimal characters, the value in the call’s record row. Quote it when you report the call."
      },
      "pending_action": {
        "allOf": [
          {
            "$ref": "#/shapes/pending_action"
          },
          {
            "type": "object",
            "properties": {
              "outcome": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "The outcome of the approved action, with the application, its time-limited production connection and the next step.",
                "properties": {
                  "application": {
                    "type": "string",
                    "description": "The ID of the application whose production database the connection reaches."
                  },
                  "connection": {
                    "type": "object",
                    "required": [
                      "id",
                      "expires_at",
                      "relay"
                    ],
                    "description": "The approved production database connection. Use the pending action ID in `turnzero db connect --grant <id>`, and use `expires_at` to see when it expires.",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "The ID of the approved database connection."
                      },
                      "expires_at": {
                        "type": "string",
                        "format": "date-time",
                        "description": "The UTC instant when the connection's grant expires, one hour after approval."
                      },
                      "relay": {
                        "type": "string",
                        "description": "The full WebSocket address of the approved connection's relay."
                      }
                    }
                  },
                  "detail": {
                    "type": "string",
                    "description": "Gives the command route and when the connection ends."
                  }
                }
              }
            }
          }
        ],
        "description": "The pending action for browser approval. A completed outcome gives the production database connection. A failed outcome gives the refusal."
      },
      "approval_url": {
        "type": "string",
        "description": "The link the person opens in a browser to approve or decline this request."
      },
      "detail": {
        "type": "string",
        "description": "Explains the browser approval and points to `read_approval_status` for the outcome."
      }
    }
  }
}

Shared contracts #