sys_uuid
Produce one or more UUIDs using version 1 (time-based) or 4 (random), with optional uppercase formatting.
Instructions
生成 UUID。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| version | No | UUID 版本:1(基于时间)或 4(随机,默认) | |
| count | No | 生成数量(1~20,默认 1) | |
| upper | No | 是否大写(默认 false) |
Implementation Reference
- The `_sys_uuid` function executes the core logic: reads args (version, count, upper), generates UUIDs using uuid1() or uuid4(), optionally uppercases them, and returns as text content.
def _sys_uuid(args: dict) -> list[types.TextContent]: version = int(args.get("version", 4)) count = max(1, min(20, int(args.get("count", 1)))) upper = bool(args.get("upper", False)) results = [] for _ in range(count): u = _uuid.uuid1() if version == 1 else _uuid.uuid4() results.append(str(u).upper() if upper else str(u)) return [types.TextContent(type="text", text="\n".join(results))] - The `sys_uuid` tool definition with inputSchema: version (1 or 4, default 4), count (1-20, default 1), upper (boolean, default false).
types.Tool( name="sys_uuid", description="生成 UUID。", inputSchema={ "type": "object", "properties": { "version": { "type": "integer", "description": "UUID 版本:1(基于时间)或 4(随机,默认)", "enum": [1, 4], "default": 4, }, "count": { "type": "integer", "description": "生成数量(1~20,默认 1)", "default": 1, }, "upper": { "type": "boolean", "description": "是否大写(默认 false)", "default": False, }, }, }, - src/onion_mcp_server/tools/system.py:175-187 (registration)The `handle_system` dispatcher registers "sys_uuid" -> `_sys_uuid` in a handlers dict, called from server.py's call_tool handler.
async def handle_system(name: str, arguments: dict) -> list[types.TextContent]: handlers = { "sys_time": _sys_time, "sys_uuid": _sys_uuid, "sys_hash": _sys_hash, "sys_base64": _sys_base64, "sys_url_encode": _sys_url_encode, "sys_json_valid": _sys_json_valid, } fn = handlers.get(name) if fn is None: raise ValueError(f"未知 system 工具: {name}") return fn(arguments) - src/onion_mcp_server/server.py:48-61 (registration)In server.py, 'sys_uuid' is registered in the _HANDLERS routing table by iterating over SYSTEM_TOOLS and mapping each tool name to handle_system.
# ── 路由表 ──────────────────────────────────────────────────── _HANDLERS: dict = {} for _t in AI_TOOLS: _HANDLERS[_t.name] = handle_ai for _t in CODE_TOOLS: _HANDLERS[_t.name] = handle_code for _t in TEXT_TOOLS: _HANDLERS[_t.name] = handle_text for _t in DATA_TOOLS: _HANDLERS[_t.name] = handle_data for _t in WEB_TOOLS: _HANDLERS[_t.name] = handle_web for _t in SYSTEM_TOOLS: _HANDLERS[_t.name] = handle_system - src/onion_mcp_server/server.py:39-46 (registration)The 'sys_uuid' Tool object is included in ALL_TOOLS via the *SYSTEM_TOOLS spread, making it available via the list_tools() MCP endpoint.
ALL_TOOLS: list[types.Tool] = [ *AI_TOOLS, *CODE_TOOLS, *TEXT_TOOLS, *DATA_TOOLS, *WEB_TOOLS, *SYSTEM_TOOLS, ]