Tool reference · Utilities
Get random numbers
Hardware-generated random integers, ready for your agent.
- MCP tool
- get_random_numbers
- MCP endpoint
- /mcp/random
- REST
- POST /v1/tools/get_random_numbers/jobs
- Price
- 1 credit per job
Overview
A seeded generator such as rand() follows a repeatable sequence. MCPBytes draws fresh randomness from physical hardware for each new job. Use it when you want an external source of chance to pick a creative direction, break a tie, roll dice, sample candidates or supply random inputs to simulations. Your agent sets the count and range and gets integers back through MCP or REST, with no local random generator to configure. Repeated values are allowed. Not for cryptographic secrets.
- Randomness
- Hardware-generated; fresh draws for new jobs
- Input
- count, min and max; no file
- Outputs
- numbers.json and numbers.txt
- Range
- Signed 32-bit bounds, min less than max
- Replay
- Reuse a request key to retrieve the same draw
14 test groups passed every check in our NIST test run on one million output bits. Explore the complete results and what each check means. NIST Randomness validation
Quickstart
Send the options as JSON. The response is the new job; poll it until its status is final, then download the files in result.files.
curl https://api.mcpbytes.com/v1/tools/get_random_numbers/jobs \
-H "Authorization: Bearer $MCPBYTES_API_KEY" \
-H "Content-Type: application/json" \
-d '{"options":{"count":10,"min":1,"max":6},"idempotency_key":"dice-example-001"}'{
"id": "j_vwzd6fj7kgy9c4xzn3d3nd922t",
"tool": "get_random_numbers",
"status": "succeeded",
"input_kind": "parameters",
"options": {
"count": 10,
"min": 1,
"max": 6
}
}curl "https://api.mcpbytes.com/v1/jobs/$JOB_ID" \
-H "Authorization: Bearer $MCPBYTES_API_KEY"{
"id": "j_vwzd6fj7kgy9c4xzn3d3nd922t",
"tool": "get_random_numbers",
"status": "succeeded",
"result": {
"numbers": [
5,
4,
3,
6,
1,
3,
2,
5,
2,
6
],
"count": 10,
"min": 1,
"max": 6,
"files": [
{
"name": "numbers.json"
},
{
"name": "numbers.txt"
}
]
}
}A job can be canceled while it is queued: POST /v1/jobs/{id}/cancel.
More on statuses, downloads and retention in Jobs & files.
Input
No file. Send the options in a JSON body, {"options": {…}}, or as arguments of the MCP tool. Keep private text such as prompts out of URLs.
idempotency_key is required. Repeating a request with the same key returns the original job instead of starting and charging a new one; reusing a key for a different request returns 409 idempotency_conflict.Options
Put options in the options object of the JSON body, or pass them as arguments of the MCP tool. Leave an option out to use its default.
- count
1–1000Number of integers; default 1.- min
-2147483648–2147483647Inclusive lower bound; default 0.- max
-2147483648–2147483647Inclusive upper bound; default 2147483647. Must exceed min.
Outputs
A succeeded job lists its files in result.files, each with a download url.
- numbers.json
- The numbers, count and inclusive min/max bounds.
- numbers.txt
- The integer array, returned inline over MCP when ready.
New jobs return HTTP 202. Replaying a completed request returns HTTP 200, as in the example. Download links last up to 24 hours, capped by output retention. Use a new idempotency key for fresh numbers; reuse a key to recover the same job after a network failure.
Result summary
Next to files, the job's result has a summary you can check without downloading anything:
- numbers
- The integers, in the order drawn.
- count, min, max
- How many, and the inclusive bounds.
Tips
- Reuse the idempotency key and options to recover the same draw after a network failure. Use a new key for fresh numbers; reusing a key with other options returns 409.
- Repeated values are allowed, and there is no seed or uniqueness guarantee. For reproducible simulation runs, use a seeded local generator.
- Not for passwords, cryptographic keys or wallet seeds. For key material, use get_random_bytes through MCPBytes Vault.
- Over MCP the numbers come back with the result. A queued job can be canceled; a running one cannot.
MCP
Your agent calls get_random_numbers. Connect it to https://api.mcpbytes.com/mcp/random for this tool, or to https://api.mcpbytes.com/mcp for every tool.
Claude CodeOAuth or API key
The first form signs in through the browser when you run /mcp. In .mcp.json (project root), ${MCPBYTES_API_KEY} is read from the environment when Claude Code connects. Claude Code docs
claude mcp add --transport http mcpbytes \
https://api.mcpbytes.com/mcp/randomCodex (CLI, IDE extension, ChatGPT desktop)OAuth or API key
Codex reads the key from the environment variable each time it connects. The same table can go in ~/.codex/config.toml by hand; codex mcp add has no --header flag. Codex docs
codex mcp add mcpbytes --url https://api.mcpbytes.com/mcp/random \
--bearer-token-env-var MCPBYTES_API_KEYCursorOAuth or API key
~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project). Remote servers take no "type". Without the header, the client signs you in with GitHub or an email link (OAuth). Cursor docs
{
"mcpServers": {
"mcpbytes": {
"url": "https://api.mcpbytes.com/mcp/random",
"headers": {
"Authorization": "Bearer ${env:MCPBYTES_API_KEY}"
}
}
}
}Arguments
The tool's options are flat arguments. Besides them:
- wait_seconds
0–45, default 30How long the call waits for the result. If the job is still running, the agent calls get_job.- max_length
16–100,000, default 20,000Bytes of numbers.txt returned with the result; read the rest with read_job_file.- idempotency_key
RequiredReuse it with the same arguments when retrying after a network error.
What the agent sees
- get_random_numbers
- Returns count random integers between min and max, inclusive, in numbers.json, with numbers.txt inline. Repeated values are allowed. A failed job is refunded. Not for cryptographic secrets. Costs 1 credits per job. Requires idempotency_key; retain it when retrying the same request.
- get_job
- Status and results of a job; waits up to wait_seconds for it to finish.
- cancel_job
- Cancel a queued job or a workflow whose can_cancel is true; repeated calls never delete results.
- list_jobs
- Your most recent jobs, newest first.
- read_job_file
- Reads a text output (.txt .json .md .csv) of a succeeded job in chunks.
Setup for every client, and how agents upload files and read results: Connect over MCP.
Agent skill
The MCPBytes skill teaches agents this tool, in references/get_random_numbers.md. Agents without MCP run it through the REST API with the skill's script, which reads your key from MCPBYTES_API_KEY:
python scripts/mcpbytes.py run get_random_numbers \
-o count=10 -o min=1 -o max=6 --out numbers/Pricing
1 credit per job. The price is charged before paid processing starts. A job that fails costs nothing: its charge is refunded.
- Per job
- 1 credit
One credit balance pays for every tool, and a new account starts with free credits. See Credits & prices or buy credits.
Limits
- Numbers
- 1–1,000 per job
- At a time
- 1 job
- Results
- 24 hours by default
GET /v1/me returns your limits and current usage; Limits & errors explains what happens when one is reached.
Errors
A failed job comes back with error.code, error.message and often error.hint. Codes are stable. Inputs that fail with a validation error will fail again unchanged.
- source_unavailable
- Generation is temporarily unavailable. Try again later.
- source_unhealthy
- Generation could not complete. A failed job costs nothing.
- timeout
- Generation exceeded its time limit; the charge is refunded.
- invalid_options
- min must be less than max and count must be within the catalog limit.
- unsupported_format
- The tool does not take this file type.
- insufficient_credits
- The job costs more than the balance, which is known once the input has been measured. Nothing was charged.
- out_of_memory
- The file needs more memory than a job has.
Requests can also fail before a job starts, with an HTTP status: see HTTP errors.