Skip to main content
Glama
Xuzan9396

YST KPI Daily Report Collector

by Xuzan9396

check_login_status

Verify login status for the YST KPI Daily Report Collector to determine if authentication is required before data collection.

Instructions

检查当前登录状态(建议第一步调用)

✅ 推荐工作流程:

  1. 首先调用此工具检查登录状态

  2. 如果返回"未登录",则调用 browser_login 进行登录

  3. 登录成功后,调用 collect_reports 采集数据

Returns: 登录状态信息: - "✓ 已登录,Cookie 有效" -> 可以直接采集数据 - "❌ Cookie 已过期" -> 需要调用 browser_login 重新登录 - "❌ 未找到保存的 Cookie" -> 需要调用 browser_login 首次登录

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'check_login_status' MCP tool, decorated with @mcp.tool() for registration. It checks if cookies exist, loads them, and verifies login status using the ReportCollector.
    @mcp.tool()
    async def check_login_status() -> str:
        """
        检查当前登录状态(建议第一步调用)
    
        ✅ 推荐工作流程:
        1. 首先调用此工具检查登录状态
        2. 如果返回"未登录",则调用 browser_login 进行登录
        3. 登录成功后,调用 collect_reports 采集数据
    
        Returns:
            登录状态信息:
            - "✓ 已登录,Cookie 有效" -> 可以直接采集数据
            - "❌ Cookie 已过期" -> 需要调用 browser_login 重新登录
            - "❌ 未找到保存的 Cookie" -> 需要调用 browser_login 首次登录
        """
        collector = ReportCollector()
    
        try:
            # 尝试加载已保存的 Cookie
            if collector.cookie_manager.has_cookies():
                collector.load_saved_cookies()
    
                # 检查登录状态
                if collector.check_login_status():
                    return safe_text("✓ 已登录,Cookie 有效")
                else:
                    return safe_text("❌ Cookie 已过期,请重新登录并保存 Cookie")
            else:
                return safe_text("❌ 未找到保存的 Cookie,请先使用 save_cookies_from_browser 工具保存登录信息")
        except Exception as e:
            return safe_text(f"检查失败: {str(e)}")
  • Helper method in ReportCollector class that performs the actual login status check by sending a request to the report list URL and verifying the response.
    def check_login_status(self) -> bool:
        """
        检查是否已登录
    
        Returns:
            是否已登录
        """
        try:
            response = self.session.get(self.REPORT_LIST_URL, allow_redirects=False)
            # 如果返回 200 且不是重定向到登录页,说明已登录
            return response.status_code == 200 and 'login' not in response.url.lower()
        except Exception as e:
            print(f"检查登录状态失败: {e}")
            return False

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/Xuzan9396/yst_mcp'

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