"""Check Playwright MCP without any AI model. Starts @playwright/mcp@0.0.83 over stdio, lists its tools, opens the Playwright TodoMVC demo, adds one todo and reads it back from a snapshot. Needs Node.js and a browser Playwright can launch. No API key. python3 check_playwright_mcp.py """ import glob import json import re import subprocess CMD = ["npx", "-y", "@playwright/mcp@0.0.83", "--headless", "--isolated", "--output-dir", "pw-check-output"] proc = subprocess.Popen(CMD, stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) next_id = 0 def rpc(method, params=None, notify=False): global next_id msg = {"jsonrpc": "2.0", "method": method, "params": params or {}} if not notify: next_id += 1 msg["id"] = next_id proc.stdin.write(json.dumps(msg) + "\n") proc.stdin.flush() while not notify: reply = json.loads(proc.stdout.readline()) if reply.get("id") == next_id: return reply def call(name, args): reply = rpc("tools/call", {"name": name, "arguments": args}) return "\n".join(c.get("text", "") for c in reply["result"]["content"]) def latest_snapshot(): return open(sorted(glob.glob("pw-check-output/page-*.yml"))[-1]).read() try: rpc("initialize", {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "kit-check", "version": "1"}}) rpc("notifications/initialized", notify=True) tools = [t["name"] for t in rpc("tools/list")["result"]["tools"]] print("tools:", len(tools)) call("browser_navigate", {"url": "https://demo.playwright.dev/todomvc/"}) ref = re.search(r'textbox "What needs to be done\?".*?\[ref=(\w+)\]', latest_snapshot()).group(1) call("browser_type", {"element": "New todo input", "target": ref, "text": "Write the kit", "submit": True}) call("browser_snapshot", {}) snap = latest_snapshot() print("todo added:", "Write the kit" in snap) print("counter:", re.search(r"text: (item[s]? left)", snap).group(1)) call("browser_close", {}) finally: proc.kill()