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 ( |
| Fields | |
|---|---|
commitTimestamp |
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: |
commitStats |
The statistics about this |
snapshotTimestamp |
If 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: |
Union field MultiplexedSessionRetry. You must examine and retry the commit if the following is populated. MultiplexedSessionRetry can be only one of the following: |
|
precommitToken |
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: ❌