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
| Parameter | Type | Required | Description |
|---|---|---|---|
count | integer | No | Number of UUIDs to generate (1–100). Default: 1. |
Response
| Field | Type | Description |
|---|---|---|
uuids | array of strings | The generated UUIDs as lowercase hyphenated strings. |
version | string | Always "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).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | count is not an integer, or an argument is the wrong type. | protocol error (invalid_params) |
count_out_of_range | count is 0 or greater than 100. | tool error (isError) |
internal_error | An 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.