rotate_api_key
Generate a new workspace API key and immediately invalidate the current one. This irreversible action requires updating all integrations and restarting the server.
Instructions
Generate a new workspace API key and immediately invalidate the current one.
WARNING: This action is irreversible. The moment this succeeds, the key used to call it stops working. All integrations must be updated with the new key immediately, and this MCP server must be restarted with the new BITSCALE_API_KEY environment variable.
Returns: {"api_key": "sk-live-newkey..."} — the new workspace API key.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- main.py:305-318 (handler)The rotate_api_key function that executes the tool logic. It calls POST /api-key/rotate to generate a new API key and invalidate the current one. Returns the new API key as a JSON string.
@mcp.tool() def rotate_api_key() -> str: """ Generate a new workspace API key and immediately invalidate the current one. WARNING: This action is irreversible. The moment this succeeds, the key used to call it stops working. All integrations must be updated with the new key immediately, and this MCP server must be restarted with the new BITSCALE_API_KEY environment variable. Returns: {"api_key": "sk-live-newkey..."} — the new workspace API key. """ data = _post("/api-key/rotate") return json.dumps(data, indent=2) - main.py:56-62 (helper)The _post helper function used by rotate_api_key to make authenticated POST requests to the BitScale API.
def _post(path: str, body: dict | None = None, timeout: int = 60) -> dict: """Perform an authenticated POST request against the BitScale API.""" url = f"{BITSCALE_API_BASE}{path}" with httpx.Client(timeout=timeout) as client: response = client.post(url, headers=_headers(), json=body or {}) response.raise_for_status() return response.json() - main.py:31-31 (registration)The FastMCP server instance ('mcp') that registers rotate_api_key via @mcp.tool() decorator on line 305.
mcp = FastMCP("BitScale")