Back to home
Connect a client

Attach a database to the app

Write the database's internal connection string into a secret environment variable of its project (DATABASE_URL for PostgreSQL, REDIS_URL for Redis, or envVar) without returning it, so the password never passes through your client. HTTP 409 database_not_ready means the database has no connection details yet; variable_exists means the variable already holds a different value: send replace: true to overwrite it, which also needs configuration:write. Deploy or restart the project afterwards so the app reads the variable.

Arguments

NameTypeRequiredLimits
envVarstringNoAt least 1 character(s)
replacebooleanNoSee schema
projectIdstringYesAt least 1 character(s)
databaseIdstringYesAt least 1 character(s)
Full input schema
{
  "type": "object",
  "properties": {
    "envVar": {
      "type": "string",
      "minLength": 1
    },
    "replace": {
      "type": "boolean"
    },
    "projectId": {
      "type": "string",
      "minLength": 1
    },
    "databaseId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "projectId",
    "databaseId"
  ],
  "additionalProperties": false
}

Example call

The params of a tools/call request. Replace the placeholder values with your own IDs.

{
  "name": "attachDatabase",
  "arguments": {
    "projectId": "REPLACE_WITH_PROJECT_ID",
    "databaseId": "REPLACE_WITH_DATABASE_ID"
  }
}

Result

The same data as the API operation, wrapped as {"untrusted_data": true, "source": "attachDatabase", "note": "...", "data": ...} so the model treats project content as data, not instructions.