Skip to main content

uuid_generate_v7

Generate one or more time-ordered UUID v7 strings (RFC 9562). Each UUID embeds a millisecond-precision Unix timestamp in the most-significant bits, so UUIDs generated later sort lexicographically after UUIDs generated earlier.

Use v7 for database primary keys where B-tree index locality matters. For opaque, unpredictable identifiers use uuid_generate_v4.

Parameters​

ParameterTypeRequiredDescription
countintegerNoNumber of UUIDs to generate (1–100). Default: 1.

Response​

FieldTypeDescription
uuidsarray of stringsThe generated UUIDs as lowercase hyphenated strings.
versionstringAlways "v7".

Examples​

Generate a single time-ordered UUID​

{}

Result:

{
"uuids": ["0190d3a2-f4b1-7c3e-9a47-5d82b06e1f83"],
"version": "v7"
}

Generate three UUIDs for bulk insert​

{
"count": 3
}

Result:

{
"uuids": [
"0190d3a2-f4b1-7c3e-9a47-5d82b06e1f83",
"0190d3a2-f4b2-7d9f-b316-8c4a1e0f2d57",
"0190d3a2-f4b3-7a81-af52-3e6b9c2d4087"
],
"version": "v7"
}

Errors​

Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).

CodeWhenDelivered as
invalid_argumentscount is not an integer, or an argument is the wrong type.protocol error (invalid_params)
count_out_of_rangecount is 0 or greater than 100.tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Notes​

  • All UUIDs are returned as lowercase hyphenated strings.
  • UUIDs within the same millisecond include a random suffix to ensure uniqueness.
  • Lexicographic sort order of v7 UUIDs matches insertion time order, making them ideal for clustered indexes.