xiaohongshu_check_status
Check Xiaohongshu account login status using headless browser automation to verify authentication and access permissions.
Instructions
检查小红书登录状态
Args: headless: 是否使用无头模式,默认True(状态检查可使用无头模式) chrome_path: Chrome浏览器可执行文件路径,可选
Returns: 登录状态信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chrome_path | No | ||
| headless | No |
Input Schema (JSON Schema)
{
"properties": {
"chrome_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Chrome Path"
},
"headless": {
"default": true,
"title": "Headless",
"type": "boolean"
}
},
"title": "xiaohongshu_check_statusArguments",
"type": "object"
}
Implementation Reference
- src/xiaohongshu_mcp/server.py:60-101 (handler)The handler function decorated with @mcp.tool() that implements the xiaohongshu_check_status tool. It launches a browser, creates a XiaohongshuLogin instance, and checks the login status.@mcp.tool() async def xiaohongshu_check_status( headless: bool = True, chrome_path: Optional[str] = None ) -> str: """ 检查小红书登录状态 Args: headless: 是否使用无头模式,默认True(状态检查可使用无头模式) chrome_path: Chrome浏览器可执行文件路径,可选 Returns: 登录状态信息 """ try: logger.info("检查小红书登录状态...") # 创建浏览器管理器 browser_manager = BrowserManager( headless=headless, chrome_path=chrome_path ) async with browser_manager.get_page() as page: # 创建登录处理器 login_handler = XiaohongshuLogin(page) # 检查登录状态 is_logged_in = await login_handler.check_login_status() if is_logged_in: logger.success("✅ 已登录") return "✅ 小红书已登录" else: logger.info("❌ 未登录") return "❌ 小红书未登录,请先执行登录操作" except Exception as e: error_msg = f"检查登录状态时发生错误: {e}" logger.error(error_msg) return f"❌ {error_msg}"
- src/xiaohongshu_mcp/server.py:60-60 (registration)The @mcp.tool() decorator registers the xiaohongshu_check_status function as an MCP tool.@mcp.tool()
- src/xiaohongshu_mcp/server.py:61-74 (schema)Input schema defined by function parameters (headless: bool, chrome_path: Optional[str]) and return str, with docstring describing the tool.async def xiaohongshu_check_status( headless: bool = True, chrome_path: Optional[str] = None ) -> str: """ 检查小红书登录状态 Args: headless: 是否使用无头模式,默认True(状态检查可使用无头模式) chrome_path: Chrome浏览器可执行文件路径,可选 Returns: 登录状态信息 """