Skip to main content
Glama

restart_astrbot

Restarts the AstrBot Core service to apply changes or resolve issues. Waits for the bot to become available after restart.

Instructions

重启 AstrBot Core,对应 /api/stat/restart-core。 重启后会等待 AstrBot 重新启动并可用。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of the 'restart_astrbot' tool. This async function restarts the AstrBot core using the API and polls the version endpoint to confirm it's back online, with timeout handling.
    async def restart_astrbot() -> Dict[str, Any]: """ 重启 AstrBot Core,对应 /api/stat/restart-core。 重启后会等待 AstrBot 重新启动并可用。 """ client = AstrBotClient.from_env() try: # 先调用重启接口 restart_resp = await client.restart_core() # 如果重启接口返回错误,直接返回 if restart_resp.get("status") != "ok": return restart_resp # 等待 AstrBot 重启完成 # 通过轮询 /api/stat/version 接口来检测 AstrBot 是否已经重启完成 max_wait_time = 60 # 最大等待时间 60 秒 check_interval = 2 # 每 2 秒检查一次 elapsed_time = 0 while elapsed_time < max_wait_time: try: # 尝试获取版本信息,如果成功说明 AstrBot 已经重启完成 version_resp = await client.get_version() if version_resp.get("status") == "ok": return { "status": "ok", "message": "AstrBot 重启成功", "restart_response": restart_resp, "wait_time": elapsed_time } except Exception: # 如果请求失败,说明 AstrBot 还在重启中,继续等待 pass # 等待一段时间后再次检查 await asyncio.sleep(check_interval) elapsed_time += check_interval # 如果等待超时,返回错误 return { "status": "error", "message": f"AstrBot 重启超时(等待 {max_wait_time} 秒后仍未响应)", "restart_response": restart_resp, "wait_time": elapsed_time } except Exception as e: return { "status": "error", "message": f"AstrBot API error: {e.response.status_code if hasattr(e, 'response') else 'Unknown'}", "base_url": client.base_url, "detail": _httpx_error_detail(e), }
  • Registers the restart_astrbot tool handler with the FastMCP server under the name 'restart_astrbot'.
    server.tool(astrbot_tools.restart_astrbot, name="restart_astrbot")
  • Imports and re-exports the restart_astrbot handler from control_tools.py into the tools package namespace.
    from .control_tools import restart_astrbot
  • Lists 'restart_astrbot' in the tool resource info for MCP host discovery.
    "restart_astrbot",
  • Re-exports restart_astrbot for backward compatibility in the top-level tools module.
    restart_astrbot,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xunxiing/astrbotmcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server