MCP Tools Reference: cloud-sql

工具:list_users

列出 Cloud SQL 執行個體的所有資料庫使用者。

以下範例示範如何使用 curl 叫用 list_users MCP 工具。

Curl 要求
                  
curl --location 'https://sqladmin.googleapis.com/mcp' \
--header 'content-type: application/json' \
--header 'accept: application/json, text/event-stream' \
--data '{
  "method": "tools/call",
  "params": {
    "name": "list_users",
    "arguments": {
      // provide these details according to the tool's MCP specification
    }
  },
  "jsonrpc": "2.0",
  "id": 1
}'
                

輸入內容的結構定義

SqlUsersListRequest

JSON 表示法
{
  "instance": string,
  "project": string
}
欄位
instance

string

資料庫執行個體 ID。這不包括專案 ID。

project

string

包含執行個體的專案 ID。

輸出內容的結構定義

使用者清單回應。

UsersListResponse

JSON 表示法
{
  "kind": string,
  "items": [
    {
      object (User)
    }
  ],
  "nextPageToken": string
}
欄位
kind

string

這個值一律為 sql#usersList

items[]

object (User)

執行個體中的使用者資源清單。

nextPageToken
(deprecated)

string

未使用。

使用者

JSON 表示法
{
  "kind": string,
  "password": string,
  "etag": string,
  "name": string,
  "host": string,
  "instance": string,
  "project": string,
  "type": enum (SqlUserType),
  "iamEmail": string,
  "passwordPolicy": {
    object (UserPasswordValidationPolicy)
  },
  "databaseRoles": [
    string
  ],

  // Union field user_details can be only one of the following:
  "sqlserverUserDetails": {
    object (SqlServerUserDetails)
  }
  // End of list of possible types for union field user_details.

  // Union field _dual_password_type can be only one of the following:
  "dualPasswordType": enum (DualPasswordType)
  // End of list of possible types for union field _dual_password_type.

  // Union field _iam_status can be only one of the following:
  "iamStatus": enum (IamStatus)
  // End of list of possible types for union field _iam_status.
}
欄位
kind

string

這個值一律為 sql#user

password

string

使用者的密碼。

etag

string

這個欄位已淘汰,將從日後的 API 版本中移除。

name

string

Cloud SQL 執行個體中的使用者名稱。可省略 update,因為網址中已指定。

host

string

選用。使用者可連線的主機。如果是 insert 作業,主機預設為空字串。如果是 update 作業,主機是在要求網址中指定。插入後就無法更新主機名稱。如果是 MySQL 執行個體,則為必要項目;如果是 PostgreSQL 或 SQL Server 執行個體,則為選用項目。

instance

string

Cloud SQL 執行個體的名稱。這不包括專案 ID。可省略 update,因為網址中已指定。

project

string

含有 Cloud SQL 資料庫的專案 ID。如果適用,Google 應用程式網域會加上前置字元。可省略 update,因為網址中已指定。

type

enum (SqlUserType)

使用者類型。這項設定會決定登入時驗證使用者的方法。預設值為資料庫的內建使用者類型。

iamEmail

string

選用。IAM 使用者的完整電子郵件地址。一般資料庫使用者不會填寫這項資訊。僅適用於 MySQL 資料庫使用者。

passwordPolicy

object (UserPasswordValidationPolicy)

使用者層級密碼驗證政策。

databaseRoles[]

string

選用。使用者的角色成員資格

聯集欄位 user_details。特定資料庫類型 user_details 的使用者詳細資料只能是下列其中一項:
sqlserverUserDetails

object (SqlServerUserDetails)

聯集欄位 _dual_password_type

_dual_password_type 只能是下列其中一項:

dualPasswordType

enum (DualPasswordType)

使用者的雙重密碼狀態。

聯集欄位 _iam_status

_iam_status 只能是下列其中一項:

iamStatus

enum (IamStatus)

指出群組是否處於有效狀態,可進行 IAM 資料庫驗證。

SqlServerUserDetails

JSON 表示法
{
  "disabled": boolean,
  "serverRoles": [
    string
  ]
}
欄位
disabled

boolean

如果使用者已遭停用

serverRoles[]

string

這位使用者的伺服器角色

UserPasswordValidationPolicy

JSON 表示法
{
  "allowedFailedAttempts": integer,
  "passwordExpirationDuration": string,
  "enableFailedAttemptsCheck": boolean,
  "status": {
    object (PasswordStatus)
  },
  "enablePasswordVerification": boolean
}
欄位
allowedFailedAttempts

integer

使用者登入失敗次數上限 (一旦超出上限,帳戶即會遭到鎖定)。

passwordExpirationDuration

string (Duration format)

密碼更新後的到期時間。

時間長度以秒為單位,最多可有 9 個小數位數,並應以「s」結尾,例如:"3.5s"

enableFailedAttemptsCheck

boolean

如果為 true,系統會啟用失敗的嘗試登入次數檢查。

status

object (PasswordStatus)

僅供輸出。唯讀密碼狀態。

enablePasswordVerification

boolean

如果為 true,使用者必須先指定目前的密碼,才能變更密碼。這個標記僅適用於 MySQL。

時間長度

JSON 表示法
{
  "seconds": string,
  "nanos": integer
}
欄位
seconds

string (int64 format)

時間範圍的簽署秒數。必須介於 -315,576,000,000 至 +315,576,000,000 之間 (含這兩個值)。注意:這些界限是根據以下計算得出:60 秒/分鐘 * 60 分鐘/小時 * 24 小時/天 * 365.25 天/年 * 10000 年

nanos

integer

時間跨度的小數部分 (以奈秒為單位),可為正數或負數。如果時間長度不到一秒,系統會以 0 seconds 欄位和正數或負數 nanos 欄位表示。如果時間長度為一秒以上,nanos 欄位的非零值必須與 seconds 欄位相同。值必須介於 -999,999,999 到 +999,999,999 之間 (含)。

PasswordStatus

JSON 表示法
{
  "locked": boolean,
  "passwordExpirationTime": string
}
欄位
locked

boolean

如果設為 true,表示使用者沒有登入權限。

passwordExpirationTime

string (Timestamp format)

目前密碼的到期時間。

使用 RFC 3339,產生的輸出內容一律會經過 Z 正規化,並使用 0、3、6 或 9 個小數位數,也接受「Z」以外的偏移量。範例:"2014-10-02T15:01:23Z""2014-10-02T15:01:23.045123456Z""2014-10-02T15:01:23+05:30"

時間戳記

JSON 表示法
{
  "seconds": string,
  "nanos": integer
}
欄位
seconds

string (int64 format)

代表自 Unix 紀元 1970-01-01T00:00:00Z 起算的世界標準時間秒數。必須介於 -62135596800 和 253402300799 之間 (含),對應至 0001-01-01T00:00:00Z 至 9999-12-31T23:59:59Z。

nanos

integer

以奈秒為單位的非負秒數小數。這個欄位是時間長度的奈秒部分,並非秒數的替代值。如果秒數值為負數,且包含小數,奈秒值仍須為非負數,且會向前計時。必須介於 0 至 999,999,999 之間 (含)。

工具註解

破壞性提示:❌ | 等冪提示:❌ | 唯讀提示:✅ | 開放世界提示:❌