Skip to main content
Glama
Xuzan9396

YST KPI Daily Report Collector

by Xuzan9396

save_cookies_from_browser

Save browser cookies for persistent login session to enable automated collection of daily KPI report data.

Instructions

保存浏览器 Cookie(用于首次登录)

使用方法:

  1. 使用 chrome_devtools_mcp 登录 https://kpi.drojian.dev

  2. 登录成功后,从浏览器复制 Cookie 字符串

  3. 调用此工具保存 Cookie

Args: cookie_string: Cookie 字符串,格式如 "name1=value1; name2=value2" 或者完整的 curl 命令中的 -b 参数内容

Returns: 保存结果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cookie_stringYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:163-164 (registration)
    Tool registration via @mcp.tool() decorator on FastMCP instance
    @mcp.tool()
    async def save_cookies_from_browser(cookie_string: str) -> str:
  • Main handler: accepts cookie_string, parses via ReportCollector.load_cookies_from_string(), saves via ReportCollector.save_current_cookies()
    async def save_cookies_from_browser(cookie_string: str) -> str:
        """
        保存浏览器 Cookie(用于首次登录)
    
        使用方法:
        1. 使用 chrome_devtools_mcp 登录 https://kpi.drojian.dev
        2. 登录成功后,从浏览器复制 Cookie 字符串
        3. 调用此工具保存 Cookie
    
        Args:
            cookie_string: Cookie 字符串,格式如 "name1=value1; name2=value2"
            或者完整的 curl 命令中的 -b 参数内容
    
        Returns:
            保存结果
        """
        collector = ReportCollector()
    
        try:
            # 加载 Cookie
            if collector.load_cookies_from_string(cookie_string):
                # 保存到文件
                if collector.save_current_cookies():
                    return safe_text("✓ Cookie 保存成功!现在可以使用 collect_reports 工具采集数据了")
                else:
                    return safe_text("❌ Cookie 保存失败")
            else:
                return safe_text("❌ Cookie 格式错误")
        except Exception as e:
            return safe_text(f"保存失败: {str(e)}")
  • Docstring/input schema describing the cookie_string parameter format and tool usage
    """
    保存浏览器 Cookie(用于首次登录)
    
    使用方法:
    1. 使用 chrome_devtools_mcp 登录 https://kpi.drojian.dev
    2. 登录成功后,从浏览器复制 Cookie 字符串
    3. 调用此工具保存 Cookie
    
    Args:
        cookie_string: Cookie 字符串,格式如 "name1=value1; name2=value2"
        或者完整的 curl 命令中的 -b 参数内容
    
    Returns:
        保存结果
    """
  • ReportCollector.load_cookies_from_string() - parses browser cookie string into dict
    def load_cookies_from_string(self, cookie_string: str) -> bool:
        """
        从 Cookie 字符串加载(浏览器复制的格式)
    
        Args:
            cookie_string: Cookie 字符串,格式如 "name1=value1; name2=value2"
    
        Returns:
            是否加载成功
        """
        try:
            cookie_dict = {}
            for item in cookie_string.split('; '):
                if '=' in item:
                    name, value = item.split('=', 1)
                    cookie_dict[name] = value
            return self.load_cookies_from_dict(cookie_dict)
        except Exception as e:
            print(f"解析 Cookie 字符串失败: {e}")
            return False
  • ReportCollector.save_current_cookies() - persists current session cookies via CookieManager
    def save_current_cookies(self) -> bool:
        """保存当前 session 的 Cookie"""
        cookies = []
        for cookie in self.session.cookies:
            cookies.append({
                'name': cookie.name,
                'value': cookie.value,
                'domain': cookie.domain,
                'path': cookie.path,
            })
        return self.cookie_manager.save_cookies(cookies)
Behavior3/5

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

No annotations are provided, so the description bears full responsibility. It mentions saving cookies and the expected input format, but does not disclose side effects (e.g., overwriting existing cookies), validation behavior, or error handling. Basic transparency but lacks depth.

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 well-structured with sections for usage, args, and returns. It is front-loaded with the purpose. While not extremely concise, all sentences are informative and no waste is present.

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?

The tool is simple, but the description omits details like behavior on repeated calls, success/failure responses, and integration with sibling tools. Given the presence of a return value, more detail on the output would improve completeness.

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

Parameters5/5

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

The input schema has 0% description coverage, but the description fully compensates by specifying the expected format ("name1=value1; name2=value2" or curl -b argument). This adds significant meaning beyond the bare schema.

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

Purpose5/5

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

The description clearly states the tool saves browser cookies for first login, distinguishing it from sibling tools like browser_login, check_login_status, and clear_saved_cookies. It specifies the resource (cookies) and action (save).

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 a step-by-step usage guide, explaining when to use the tool (after manual login via chrome_devtools_mcp and copying cookie string). It does not explicitly exclude other scenarios, but the context is clear.

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

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