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

Output 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,
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It discloses that the tool triggers a restart and waits for AstrBot to become available again, which is useful behavioral context. However, it lacks details on permissions required, whether it's idempotent, potential downtime duration, or error handling (e.g., what happens if restart fails).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly explain the action and post-action behavior. It's front-loaded with the core purpose. While efficient, it could be slightly more structured by explicitly separating purpose from behavioral notes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a system restart operation with no annotations), the description is minimally adequate. It explains what the tool does but lacks critical context like permissions, side effects, or error scenarios. The presence of an output schema helps, but the description doesn't leverage it to clarify return values or success criteria.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's effect. A baseline of 4 is applied as per rules for 0-param tools.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('重启' meaning restart) and the target resource ('AstrBot Core'), making the purpose understandable. It distinguishes from siblings by focusing on core restart rather than configuration, messaging, or logging operations. However, it doesn't explicitly contrast with potential similar tools like 'apply_astrbot_config_ops' which might also affect system state.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing admin permissions), when it's appropriate (e.g., after config changes, during troubleshooting), or what side effects might occur (e.g., temporary service interruption). Without such context, an agent might misuse it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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