import json, sys, urllib.request sys.stdout.reconfigure(encoding='utf-8') URL = "http://127.0.0.1:8000/mcp" HEADERS = {"Content-Type": "application/json", "Accept": "application/json, text/event-stream"} def post(body, session=None, timeout=120): h = dict(HEADERS) if session: h["mcp-session-id"] = session req = urllib.request.Request(URL, data=json.dumps(body).encode(), headers=h, method="POST") resp = urllib.request.urlopen(req, timeout=timeout) sid = resp.headers.get("mcp-session-id", session) result = None for raw in resp: line = raw.decode("utf-8", "replace").strip() if not line or line.startswith(":"): continue if line.startswith("data:"): try: d = json.loads(line[5:].strip()) except Exception: continue if isinstance(d, dict) and ("result" in d or "error" in d): result = d break return sid, result sid, _ = post({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": {"name": "pi", "version": "1.0"}}}, timeout=30) h = dict(HEADERS); h["mcp-session-id"] = sid urllib.request.urlopen(urllib.request.Request(URL, data=json.dumps({"jsonrpc": "2.0", "method": "notifications/initialized"}).encode(), headers=h, method="POST"), timeout=15).read() _, res = post({"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}, session=sid, timeout=60) for t in res["result"]["tools"]: if t["name"] == "lanhu_get_ai_analyze_page_result": print(t.get("description", "")[:6000]) print("\n=== INPUT SCHEMA ===") print(json.dumps(t.get("inputSchema", {}), ensure_ascii=False, indent=1))