feat(M0): MCP 手机控制 Server 骨架——FastMCP HTTP 传输(8033),平台登录会话+CSRF 封装,de_list_devices/de_screenshot(图像块)/de_tap/de_swipe,写门控/白名单/审计,实测全链路通过
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""审计日志:每次 MCP 调用记录一行(含只读)。"""
|
||||
import json
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
_file = None
|
||||
|
||||
|
||||
def init(path):
|
||||
global _file
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
_file = open(path, "a", encoding="utf-8")
|
||||
audit("system", "startup", "", "")
|
||||
|
||||
|
||||
def audit(tool, serial, args_summary, result):
|
||||
global _file
|
||||
if _file is None:
|
||||
return
|
||||
rec = {"ts": datetime.now().isoformat(timespec="seconds"),
|
||||
"tool": tool, "serial": serial,
|
||||
"args": str(args_summary)[:200], "result": str(result)[:200]}
|
||||
try:
|
||||
_file.write(json.dumps(rec, ensure_ascii=False) + "\n")
|
||||
_file.flush()
|
||||
except Exception:
|
||||
pass
|
||||
Reference in New Issue
Block a user