uuid_generate_v4
Generate one or more random UUID v4 strings (RFC 4122). Each UUID is unique, unpredictable, and returned as a lowercase hyphenated string.
Use v4 when you need an opaque, unpredictable identifier and insert order does not matter. For database primary keys where sort order matters, use uuid_generate_v7.
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 "v4". |
Examples
Generate a single UUID
{}
Result:
{
"uuids": ["f47ac10b-58cc-4372-a567-0e02b2c3d479"],
"version": "v4"
}
Generate five UUIDs at once
{
"count": 5
}
Result:
{
"uuids": [
"3d6a1c84-09e2-4f57-b3a8-dc1e52f70b93",
"a7c4e291-5b3f-4d8e-9160-2f83a5c6d074",
"58f2b0e6-c17a-4392-8d4b-1e9f0a63c285",
"e9d3072c-4a8f-4b16-a5c9-7d2e083b1f46",
"14b8a5c3-f069-4e27-9d51-6c8b2a0e3f97"
],
"version": "v4"
}
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 (
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). - The result is always an array, even when
countis1. - Each UUID is independently random — there are no ordering guarantees between elements in a single batch.