MCP Tools Reference: oracledatabase.googleapis.com

Tool: database_connection_executesql

Executes a SQL statement (query, DDL, or DML) synchronously on the target Oracle Database using an active Database Connection (DatabaseConnection / DBC).

This tool connects to the database via the credentials, Oracle Wallet (if configured), and ODB Network specified on the DatabaseConnection (DBC), and returns execution results, column metadata, affected row counts, and durations.

Requirements & Prerequisites:

  • The DatabaseConnection (DBC) must exist and be in the ACTIVE state.
  • The database user must have appropriate privileges on the database to run the provided SQL statement.
  • For parameterized queries, use bind parameters with leading colon notation in the SQL (e.g. SELECT * FROM users WHERE user_id = :id) and pass matching params.

Parameters:

  • name (string, required): The fully-qualified resource name of the DatabaseConnection (DBC) to execute against. Format: projects/{project}/locations/{location}/databaseConnections/{database_connection}
  • sql_statement (string, required): The SQL query or command to execute (e.g., SELECT * FROM employees WHERE department_id = :dept_id or CREATE TABLE ...).
  • params (array of objects, optional): Bind variables for the SQL statement. Each object contains:
  • name (string, optional): The parameter name without the leading colon (e.g., dept_id).
  • value (Value, required): The parameter value (string, number, boolean, etc.).
  • type_name (string, optional): Datatype hint (e.g., VARCHAR2, NUMBER, DATE).

The following code sample shows how to use curl to call the database_connection_executesql MCP tool.

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

Input Schema

The request for DatabaseConnection.ExecuteSql.

ExecuteSqlRequest

JSON representation
{
  "name": string,
  "sqlStatement": string,
  "params": [
    {
      object (SqlParameter)
    }
  ]
}
Fields
name

string

Required. The name of the DatabaseConnection in the following format: projects/{project}/locations/{location}/databaseConnections/{database_connection}.

sqlStatement

string

Required. The SQL statement to execute.

params[]

object (SqlParameter)

Optional. Optional: Bind variables (parameters) to be used with the SQL statement. Supports named bind variables (e.g., :dept_id, :status in Oracle SQL) or positional parameters (:1, :2).

SqlParameter

JSON representation
{
  "name": string,
  "value": value,
  "typeName": string
}
Fields
name

string

Optional. The name of the SQL bind parameter (excluding the leading colon, e.g. "id"). If omitted, parameters bind positionally based on their order in the list.

value

value (Value format)

Required. Use protobuf.Value so clients can pass ints, bools, and strings natively.

typeName

string

Optional. Optional: Datatype hint for the parameter (e.g., "VARCHAR2", "NUMBER", "DATE", "TIMESTAMP"). If omitted, the Oracle driver will infer the type from the value string.

Value

JSON representation
{

  // Union field kind can be only one of the following:
  "nullValue": null,
  "numberValue": number,
  "stringValue": string,
  "boolValue": boolean,
  "structValue": {
    object
  },
  "listValue": array
  // End of list of possible types for union field kind.
}
Fields
Union field kind. The kind of value. kind can be only one of the following:
nullValue

null

Represents a JSON null.

numberValue

number

Represents a JSON number. Must not be NaN, Infinity or -Infinity, since those are not supported in JSON. This also cannot represent large Int64 values, since JSON format generally does not support them in its number type.

stringValue

string

Represents a JSON string.

boolValue

boolean

Represents a JSON boolean (true or false literal in JSON).

structValue

object (Struct format)

Represents a JSON object.

listValue

array (ListValue format)

Represents a JSON array.

Struct

JSON representation
{
  "fields": {
    string: value,
    ...
  }
}
Fields
fields

map (key: string, value: value (Value format))

Unordered map of dynamically typed values.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

FieldsEntry

JSON representation
{
  "key": string,
  "value": value
}
Fields
key

string

value

value (Value format)

ListValue

JSON representation
{
  "values": [
    value
  ]
}
Fields
values[]

value (Value format)

Repeated field of dynamically typed values.

NullValue

Represents a JSON null.

NullValue is a sentinel, using an enum with only one value to represent the null value for the Value type union.

A field of type NullValue with any value other than 0 is considered invalid. Most ProtoJSON serializers will emit a Value with a null_value set as a JSON null regardless of the integer value, and so will round trip to a 0 value.

Enums
NULL_VALUE Null value.

Output Schema

Execute a SQL statement response.

ExecuteSqlResponse

JSON representation
{
  "sqlResults": [
    {
      object (SqlResult)
    }
  ],
  "metadata": {
    object (ExecuteSqlMetadata)
  }
}
Fields
sqlResults[]

object (SqlResult)

SqlResult represents the results for the execution of sql statements.

metadata

object (ExecuteSqlMetadata)

Any additional metadata information regarding the execution of the sql statement.

SqlResult

JSON representation
{
  "columns": [
    {
      object (Column)
    }
  ],
  "rows": [
    {
      object (Row)
    }
  ]
}
Fields
columns[]

object (Column)

List of columns included in the result, including data type.

rows[]

object (Row)

Rows returned by the SQL statement.

Column

JSON representation
{
  "name": string,
  "type": string
}
Fields
name

string

Required. Name of the column.

type

string

Required. Database-specific type name (e.g., "VARCHAR2(255)", "NUMBER", "DATE", "CLOB")

Row

JSON representation
{
  "values": [
    {
      object (Value)
    }
  ]
}
Fields
values[]

object (Value)

List of values in a row of sql result.

Value

JSON representation
{
  "value": string,

  // Union field _null_value can be only one of the following:
  "nullValue": boolean
  // End of list of possible types for union field _null_value.
}
Fields
value

string

The cell value represented in string format. Timestamps should be converted using RFC3339Nano format.

Union field _null_value.

_null_value can be only one of the following:

nullValue

boolean

Set to true if the cell value is NULL.

ExecuteSqlMetadata

JSON representation
{
  "message": string,
  "partialResult": boolean,
  "executionDuration": string,
  "status": enum (Status)
}
Fields
message

string

Message related to SQL execution. This field can be used to convey size limit related message.

partialResult

boolean

Set to true if SQL returned a result set larger than the acceptable response size limits and the result was truncated.

executionDuration

string (Duration format)

The time duration taken to execute the sql statement.

A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".

status

enum (Status)

Output only. Status of SQL execution.

Duration

JSON representation
{
  "seconds": string,
  "nanos": integer
}
Fields
seconds

string (int64 format)

Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years

nanos

integer

Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 seconds field and a positive or negative nanos field. For durations of one second or more, a non-zero value for the nanos field must be of the same sign as the seconds field. Must be from -999,999,999 to +999,999,999 inclusive.

Status

Status contains all valid statuses a SQL execution can end up in.

Enums
STATUS_UNSPECIFIED Default value. Not returned by the service.
OK No error during SQL execution i.e. All SQL statements ran to completion. The "message" will be empty.
PARTIAL Same as OK, except indicates that only partial results were returned. The "message" field will contain details on why results were truncated. partial_result is true if and only if status is PARTIAL.
ERROR The database returned an error while executing the SQL statement. message contains the error text returned by Oracle. sql_results is empty. The statement runs in autocommit mode; which changes are committed or rolled back follows Oracle Database behavior. Authentication failures, database availability errors, network errors, and timeouts are returned as API errors (AIP-193), not as ERROR.

Tool Annotations

Tool annotations are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.

Along with the title string, the following boolean hints are defined as follows:

  • readOnlyHint: If true, the tool doesn't modify its environment. Default: false.
  • destructiveHint: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.
  • idempotentHint: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.
  • openWorldHint: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.

Destructive Hint: ✅ | Idempotent Hint: ❌ | Read Only Hint: ❌ | Open World Hint: ❌