Skip to main content
Glama

get_astrbot_logs

Retrieve AstrBot operational logs for debugging and monitoring, supporting immediate access to historical data or real-time streaming of new events.

Instructions

获取 AstrBot 日志。

  • 如果 wait_seconds <= 0:立即返回 /api/log-history 的数据。

  • 如果 wait_seconds > 0:通过 /api/live-log SSE 持续读取指定秒数内的新日志。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
wait_secondsNo
max_eventsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_astrbot_logs' tool. It fetches AstrBot logs either from history (if wait_seconds <= 0) or live stream (if > 0), handling errors gracefully and returning structured JSON.
    async def get_astrbot_logs(
        wait_seconds: int = 0,
        max_events: int = 200,
    ) -> Dict[str, Any]:
        """
        获取 AstrBot 日志。
    
        - 如果 wait_seconds <= 0:立即返回 /api/log-history 的数据。
        - 如果 wait_seconds > 0:通过 /api/live-log SSE 持续读取指定秒数内的新日志。
        """
        client = AstrBotClient.from_env()
    
        if wait_seconds > 0:
            try:
                events = await client.get_live_logs(
                    wait_seconds=wait_seconds,
                    max_events=max_events,
                )
                return {
                    "mode": "live",
                    "wait_seconds": wait_seconds,
                    "events": events,
                }
            except Exception as e:
                # 避免异常直接向 MCP 宿主抛出导致 "Error calling tool",
                # 而是把错误信息封装到正常的返回结构中,方便前端展示。
                return {
                    "mode": "live",
                    "wait_seconds": wait_seconds,
                    "status": "error",
                    "message": str(e),
                }
    
        try:
            history = await client.get_log_history()
        except Exception as e:
            return {
                "mode": "history",
                "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),
            }
    
        status = history.get("status")
        if status != "ok":
            return {
                "mode": "history",
                "status": status,
                "message": history.get("message"),
                "raw": history,
            }
    
        return {
            "mode": "history",
            "logs": history.get("data", {}).get("logs", []),
        }
  • Registers the get_astrbot_logs tool with the FastMCP server instance.
    server.tool(astrbot_tools.get_astrbot_logs, name="get_astrbot_logs")
  • Lists 'get_astrbot_logs' in the server info resource for discovery.
    "get_astrbot_logs",
  • Re-exports the get_astrbot_logs function from log_tools for convenient import.
    from .log_tools import get_astrbot_logs
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: the tool can operate in two modes (immediate historical retrieval vs. live streaming via SSE), mentions specific API endpoints (/api/log-history, /api/live-log), and describes time-based triggering. It doesn't cover aspects like rate limits, authentication needs, or error handling, but provides substantial operational context.

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

Conciseness5/5

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

The description is extremely concise and well-structured: a brief purpose statement followed by two bullet points that clearly explain the conditional behavior. Every sentence earns its place with no wasted words, and it's front-loaded with the core functionality.

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

Completeness4/5

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

Given the tool has an output schema (which handles return values), no annotations, and simple parameters, the description is reasonably complete. It explains the dual-mode operation and API endpoints well. The main gap is the undocumented 'max_events' parameter, but overall it provides sufficient context for an agent to understand when and how to use the tool.

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?

Schema description coverage is 0%, so the description must compensate. It explains the semantics of 'wait_seconds' thoroughly (immediate vs. streaming behavior based on value). However, it doesn't mention 'max_events' at all, leaving one of the two parameters undocumented. The description adds significant value for one parameter but misses the other.

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

Purpose3/5

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

The description states the tool '获取 AstrBot 日志' (gets AstrBot logs), which is a clear verb+resource combination. However, it doesn't distinguish this from potential sibling tools that might also retrieve logs or differentiate between historical vs. live log retrieval. The purpose is understandable but lacks specificity about what kind of logs or scope.

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

Usage Guidelines4/5

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

The description provides explicit guidance on when to use different behaviors based on the 'wait_seconds' parameter: immediate return for historical logs vs. streaming live logs. This gives clear context for parameter-driven usage. However, it doesn't mention when to use this tool versus sibling tools like 'get_platform_session_messages' or other logging-related tools that might exist.

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