Tool: commit
Commit a transaction in a given session. * If commit is finalizing the result of a DML statement then commit request should include latest precommit_token returned by execute_sql tool. * If response to commit includes another precommit_token then issue another commit call to finalize the transaction with the latest precommit_token.
The following sample demonstrate how to use curl
to invoke the commit
MCP tool.
| Curl Request |
|---|
curl --location 'https://spanner.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "commit", "arguments": { // provide these details according to the tool' s MCP specification } } , "jsonrpc" : "2.0" , "id" : 1 } ' |
Input Schema
The request for Commit
.
CommitRequest
| JSON representation |
|---|
{
"session"
:
string
,
"transactionId"
:
string
,
"precommitToken"
:
{
object (
|
| Fields | |
|---|---|
session
|
Required. The session in which the transaction to be committed is running. |
transactionId
|
Required. The transaction in which to commit. Commit a previously-started transaction. A base64-encoded string. |
precommitToken
|
Required. You must include the precommit token with the highest sequence number received in this transaction attempt. Failing to do so results in a |
MultiplexedSessionPrecommitToken
| JSON representation |
|---|
{ "precommitToken" : string , "seqNum" : integer } |
| Fields | |
|---|---|
precommitToken
|
Opaque precommit token. A base64-encoded string. |
seqNum
|
An incrementing seq number is generated on every precommit token that is returned. Clients should remember the precommit token with the highest sequence number from the current transaction attempt. |
Output Schema
The response for Commit
.
CommitResponse
| JSON representation |
|---|
{ "commitTimestamp" : string , "commitStats" : { object ( |
commitTimestamp
string (
Timestamp
format)
The Cloud Spanner timestamp at which the transaction committed.
Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z"
, "2014-10-02T15:01:23.045123456Z"
or "2014-10-02T15:01:23+05:30"
.
commitStats
object (
CommitStats
)
The statistics about this Commit
. Not returned by default. For more information, see CommitRequest.return_commit_stats
.
snapshotTimestamp
string (
Timestamp
format)
If TransactionOptions.isolation_level
is set to IsolationLevel.REPEATABLE_READ
, then the snapshot timestamp is the timestamp at which all reads in the transaction ran. This timestamp is never returned.
Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z"
, "2014-10-02T15:01:23.045123456Z"
or "2014-10-02T15:01:23+05:30"
.
MultiplexedSessionRetry
. You must examine and retry the commit if the following is populated. MultiplexedSessionRetry
can be only one of the following:precommitToken
object (
MultiplexedSessionPrecommitToken
)
If specified, transaction has not committed yet. You must retry the commit with the new precommit token.
Timestamp
| JSON representation |
|---|
{ "seconds" : string , "nanos" : integer } |
| Fields | |
|---|---|
seconds
|
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos
|
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
CommitStats
| JSON representation |
|---|
{ "mutationCount" : string } |
| Fields | |
|---|---|
mutationCount
|
The total number of mutations for the transaction. Knowing the |
MultiplexedSessionPrecommitToken
| JSON representation |
|---|
{ "precommitToken" : string , "seqNum" : integer } |
| Fields | |
|---|---|
precommitToken
|
Opaque precommit token. A base64-encoded string. |
seqNum
|
An incrementing seq number is generated on every precommit token that is returned. Clients should remember the precommit token with the highest sequence number from the current transaction attempt. |
Tool Annotations
Destructive Hint: ✅ | Idempotent Hint: ❌ | Read Only Hint: ❌ | Open World Hint: ❌

