# Utility Tools `/tools` エンドポイントはパブリックユーティリティです — 認証は不要です。サーバー側の時刻、安全な計算、乱数値が必要な LLM エージェントに有用です。 ## GET /tools/time 現在のサーバー時刻、タイムゾーン、UTC オフセットを取得します。 ```bash curl https://synapse.schaefer.zone/tools/time ``` レスポンス: ```json { "time": "2026-06-27T14:30:00.000Z", "timezone": "Europe/Berlin", "offset": 120 } ``` ユースケース:スケジューリング、タイムスタンプ、相対日付計算で「今何時か」を知る必要がある LLM エージェント。 ## GET /tools/calc 安全な電卓 — 算術のみで、`eval()` は使用しません。`+`、`-`、`*`、`/`、`%`、`(`、`)`、数値をサポートします。 ```bash curl "https://synapse.schaefer.zone/tools/calc?expr=(10+5)*3" ``` レスポンス: ```json { "result": 45, "expr": "(10+5)*3" } ``` > [!TIP] > 頭の中や文字列解析で計算する代わりにこちらを使用してください。安全(コードインジェクションの可能性なし)かつ正確です。 ### サポートされる演算子 - `+` 加算 - `-` 減算 - `*` 乗算 - `/` 除算 - `%` 剰余 - `(` `)` 括弧 - 数値(整数と小数) ### 例 ```bash curl ".../tools/calc?expr=2+2" # → 4 curl ".../tools/calc?expr=3.14*100" # → 314 curl ".../tools/calc?expr=100%7" # → 2 curl ".../tools/calc?expr=(2+3)*4-1" # → 19 ``` ## GET /tools/random 乱数値を生成します。 ```bash # UUID v4 curl "https://synapse.schaefer.zone/tools/random?type=uuid" # → { "value": "a1b2c3d4-...", "type": "uuid" } # Integer (default range 0-100) curl "https://synapse.schaefer.zone/tools/random?type=int&min=1&max=10" # → { "value": 7, "type": "int" } # Float curl "https://synapse.schaefer.zone/tools/random?type=float&min=0&max=1" # → { "value": 0.7234, "type": "float" } # Hex string curl "https://synapse.schaefer.zone/tools/random?type=hex&min=8&max=16" # → { "value": "a3f7b2c1", "type": "hex" } # Alphabetic string curl "https://synapse.schaefer.zone/tools/random?type=alpha&min=8&max=12" # → { "value": "kQmzPwXn", "type": "alpha" } ``` ### タイプパラメータ | タイプ | パラメータ | 出力 | |------|-----------|--------| | `uuid` | なし | UUID v4 文字列 | | `int` | `min`、`max`(デフォルト 0-100) | 整数 | | `float` | `min`、`max`(デフォルト 0-100) | 浮動小数点 | | `hex` | `min`、`max`(長さ範囲、デフォルト 8-16) | 16 進数文字列 | | `alpha` | `min`、`max`(長さ範囲、デフォルト 8-16) | アルファベット文字列 | ## LLM エージェントのユースケース ### ユニーク ID の生成 ```bash ID=$(curl -s .../tools/random?type=uuid | jq -r .value) curl -X POST .../memory -d "{\"key\": \"task_$ID\", ...}" ``` ### パーセンテージの計算 ```bash TOTAL=142 DONE=87 PERCENT=$(curl -s ".../tools/calc?expr=($DONE*100)/$TOTAL" | jq -r .result) echo "Progress: $PERCENT%" ``` ### 現在のタイムスタンプの取得 ```bash NOW=$(curl -s .../tools/time | jq -r .time) curl -X POST .../var -d "{\"key\": \"last_run\", \"value\": \"$NOW\"}" ``` ### テストデータの生成 ```bash for i in {1..10}; do NAME=$(curl -s ".../tools/random?type=alpha&min=5&max=10" | jq -r .value) curl -X POST .../memory -d "{\"key\": \"test_$i\", \"content\": \"$NAME\"}" done ``` ## 次のステップ - [API Overview](/docs/api/overview) — 全エンドポイントグループ - [Errors & Error Handling](/docs/api/errors)