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
ACTIVEstate. - 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 matchingparams.
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_idorCREATE 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 ( |
| Fields | |
|---|---|
name |
Required. The name of the DatabaseConnection in the following format: projects/{project}/locations/{location}/databaseConnections/{database_connection}. |
sqlStatement |
Required. The SQL statement to execute. |
params[] |
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 |
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 |
Required. Use protobuf.Value so clients can pass ints, bools, and strings natively. |
typeName |
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 |
| Fields | |
|---|---|
Union field kind. The kind of value. kind can be only one of the following: |
|
nullValue |
Represents a JSON |
numberValue |
Represents a JSON number. Must not be |
stringValue |
Represents a JSON string. |
boolValue |
Represents a JSON boolean ( |
structValue |
Represents a JSON object. |
listValue |
Represents a JSON array. |
Struct
| JSON representation |
|---|
{ "fields": { string: value, ... } } |
| Fields | |
|---|---|
fields |
Unordered map of dynamically typed values. An object containing a list of |
FieldsEntry
| JSON representation |
|---|
{ "key": string, "value": value } |
| Fields | |
|---|---|
key |
|
value |
|
ListValue
| JSON representation |
|---|
{ "values": [ value ] } |
| Fields | |
|---|---|
values[] |
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 ( |
| Fields | |
|---|---|
sqlResults[] |
SqlResult represents the results for the execution of sql statements. |
metadata |
Any additional metadata information regarding the execution of the sql statement. |
SqlResult
| JSON representation |
|---|
{ "columns": [ { object ( |
| Fields | |
|---|---|
columns[] |
List of columns included in the result, including data type. |
rows[] |
Rows returned by the SQL statement. |
Column
| JSON representation |
|---|
{ "name": string, "type": string } |
| Fields | |
|---|---|
name |
Required. Name of the column. |
type |
Required. Database-specific type name (e.g., "VARCHAR2(255)", "NUMBER", "DATE", "CLOB") |
Row
| JSON representation |
|---|
{
"values": [
{
object ( |
| Fields | |
|---|---|
values[] |
List of values in a row of sql result. |
Value
| JSON representation |
|---|
{ "value": string, // Union field |
| Fields | |
|---|---|
value |
The cell value represented in string format. Timestamps should be converted using RFC3339Nano format. |
Union field
|
|
nullValue |
Set to true if the cell value is NULL. |
ExecuteSqlMetadata
| JSON representation |
|---|
{
"message": string,
"partialResult": boolean,
"executionDuration": string,
"status": enum ( |
| Fields | |
|---|---|
message |
Message related to SQL execution. This field can be used to convey size limit related message. |
partialResult |
Set to true if SQL returned a result set larger than the acceptable response size limits and the result was truncated. |
executionDuration |
The time duration taken to execute the sql statement. A duration in seconds with up to nine fractional digits, ending with ' |
status |
Output only. Status of SQL execution. |
Duration
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
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 |
Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 |
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: ❌