check_network
Checks network connectivity to the tool download server before downloading the detection tool. If network is unavailable, manual download or network configuration is required.
Instructions
检测网络连通性
测试是否能访问工具下载服务器,用于在下载检测工具前确认网络状态。 如果网络不通,需要手动下载 jar 包或检查网络配置。
Returns: available: 网络是否可用 message: 状态描述信息
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/memory_shell_mcp/__init__.py:803-815 (registration)The MCP tool 'check_network' is registered using the @mcp.tool() decorator. This is a tool that checks network connectivity by calling the check_network_available helper function.
@mcp.tool() def check_network() -> dict: """ 检测网络连通性 测试是否能访问工具下载服务器,用于在下载检测工具前确认网络状态。 如果网络不通,需要手动下载 jar 包或检查网络配置。 Returns: available: 网络是否可用 message: 状态描述信息 """ return check_network_available() - src/memory_shell_mcp/__init__.py:803-815 (handler)The handler function for 'check_network': returns the result of check_network_available() which tests connectivity to the download server.
@mcp.tool() def check_network() -> dict: """ 检测网络连通性 测试是否能访问工具下载服务器,用于在下载检测工具前确认网络状态。 如果网络不通,需要手动下载 jar 包或检查网络配置。 Returns: available: 网络是否可用 message: 状态描述信息 """ return check_network_available() - Helper function 'check_network_available' that performs the actual network connectivity check by running a curl/wget command and returning availability status.
def check_network_available(test_url: str = "https://xget.xi-xu.me") -> dict: """检测网络是否可用""" system = platform.system().lower() if system == "windows": cmd = f'curl -s -o nul -w "%{{http_code}}" --connect-timeout 10 "{test_url}" || powershell -Command "(Invoke-WebRequest -Uri \'{test_url}\' -TimeoutSec 10 -UseBasicParsing).StatusCode"' else: cmd = f'curl -s -o /dev/null -w "%{{http_code}}" --connect-timeout 10 "{test_url}" 2>/dev/null || wget -q --spider --timeout=10 "{test_url}" && echo "200"' result = execute_local_command(cmd, timeout=30) if result["success"] or "200" in result["stdout"]: return {"available": True, "message": "网络连接正常"} else: return {"available": False, "message": f"网络连接失败: {result['stderr']}"}