arcade-mcp/toolkits/math/arcade_math/tools/random.py
Eric Gustin 5228c75dc9
Add ToolMetadata to OSS toolkits (#776)
Resolves TOO-388


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Primarily metadata/dependency additions with no changes to core tool
execution paths; risk is limited to potential packaging/import issues
from the new `arcade-mcp-server` dependency.
> 
> **Overview**
> Adds `ToolMetadata` to tool decorators across the Bright Data,
ClickHouse, MongoDB, Postgres, LinkedIn, Zendesk, and Math toolkits,
specifying *behavior* (read-only/idempotency/destructive/open-world)
and, where applicable, *service domain* classification.
> 
> Updates each toolkit package to depend on `arcade-mcp-server` (plus
local `uv` source wiring) and bumps toolkit versions accordingly; minor
`__all__` ordering tweaks in Math/Zendesk are included.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3bde3a061194e1d1b6a4e8a2ebd608b17984db4f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
2026-02-25 09:41:41 -08:00

57 lines
1.8 KiB
Python

import random
from typing import Annotated
from arcade_mcp_server.metadata import Behavior, ToolMetadata
from arcade_tdk import tool
@tool(
metadata=ToolMetadata(
behavior=Behavior(
read_only=True,
destructive=False,
idempotent=False,
open_world=False,
),
),
)
def generate_random_int(
min_value: Annotated[str, "The minimum value of the random integer as a string"],
max_value: Annotated[str, "The maximum value of the random integer as a string"],
seed: Annotated[
str | None,
"The seed for the random number generator as a string."
" If None, the current system time is used.",
] = None,
) -> Annotated[str, "A random integer between min_value and max_value as a string"]:
"""Generate a random integer between min_value and max_value (inclusive)."""
if seed is not None:
random.seed(int(seed))
return str(random.randint(int(min_value), int(max_value))) # noqa: S311
@tool(
metadata=ToolMetadata(
behavior=Behavior(
read_only=True,
destructive=False,
idempotent=False,
open_world=False,
),
),
)
def generate_random_float(
min_value: Annotated[str, "The minimum value of the random float as a string"],
max_value: Annotated[str, "The maximum value of the random float as a string"],
seed: Annotated[
str | None,
"The seed for the random number generator as a string."
" If None, the current system time is used.",
] = None,
) -> Annotated[str, "A random float between min_value and max_value as a string"]:
"""Generate a random float between min_value and max_value."""
if seed is not None:
random.seed(int(seed))
return str(random.uniform(float(min_value), float(max_value))) # noqa: S311