103 lines
3.7 KiB
Python
103 lines
3.7 KiB
Python
"""Submit Aegis402 to mcpservers.org via Playwright headless chromium.
|
|
|
|
Form spec (inspected previously):
|
|
GET https://mcpservers.org/submit
|
|
fields: name, description, url, category(select), email, terms(checkbox)
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
OUT = Path(__file__).resolve().parent.parent / "data" / "mcpservers_submit.html"
|
|
OUT.parent.mkdir(exist_ok=True)
|
|
|
|
PAYLOAD = {
|
|
"name": "Aegis402",
|
|
"description": "Pay-per-call CVE intel for AI agent dependencies — scans GHSA + CISA KEV, x402 native, USDC on Base, no signup.",
|
|
"url": "https://aegis402.vmaxbadge.ch/",
|
|
"email": "contact@vmaxbadge.ch",
|
|
}
|
|
|
|
|
|
def main() -> int:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True)
|
|
ctx = browser.new_context(user_agent="Mozilla/5.0 Aegis402-bot/0.1 (+https://aegis402.vmaxbadge.ch/)")
|
|
page = ctx.new_page()
|
|
try:
|
|
page.goto("https://mcpservers.org/submit", wait_until="networkidle", timeout=30000)
|
|
except Exception as e:
|
|
print(f"FAIL goto: {e}")
|
|
return 2
|
|
|
|
try:
|
|
page.fill('input[name="name"]', PAYLOAD["name"])
|
|
page.fill('input[name="description"], textarea[name="description"]', PAYLOAD["description"])
|
|
page.fill('input[name="url"]', PAYLOAD["url"])
|
|
page.fill('input[name="email"]', PAYLOAD["email"])
|
|
except Exception as e:
|
|
print(f"FAIL fill: {e}")
|
|
OUT.write_text(page.content())
|
|
return 3
|
|
|
|
# category select — try Security first, fallback Development
|
|
try:
|
|
sel = page.query_selector('select[name="category"]')
|
|
if sel:
|
|
opts = [o.inner_text().strip() for o in sel.query_selector_all("option")]
|
|
print("CATEGORY OPTIONS:", opts)
|
|
pick = None
|
|
for cand in ("Security", "Developer Tools", "Development", "Tools"):
|
|
for o in opts:
|
|
if cand.lower() in o.lower():
|
|
pick = o
|
|
break
|
|
if pick:
|
|
break
|
|
if pick:
|
|
page.select_option('select[name="category"]', label=pick)
|
|
print("PICKED:", pick)
|
|
except Exception as e:
|
|
print(f"WARN category: {e}")
|
|
|
|
# checkbox(es)
|
|
try:
|
|
for cb in page.query_selector_all('input[type="checkbox"]'):
|
|
if not cb.is_checked():
|
|
cb.check()
|
|
except Exception as e:
|
|
print(f"WARN checkbox: {e}")
|
|
|
|
OUT.write_text(page.content())
|
|
print(f"PRE-SUBMIT html saved to {OUT}")
|
|
|
|
# find submit button
|
|
try:
|
|
btn = page.query_selector('button[type="submit"], input[type="submit"]')
|
|
if not btn:
|
|
print("FAIL: no submit button found")
|
|
return 4
|
|
btn.click()
|
|
page.wait_for_load_state("networkidle", timeout=20000)
|
|
except Exception as e:
|
|
print(f"FAIL submit: {e}")
|
|
OUT.write_text(page.content())
|
|
return 5
|
|
|
|
post = Path(__file__).resolve().parent.parent / "data" / "mcpservers_response.html"
|
|
post.write_text(page.content())
|
|
print(f"POST-SUBMIT html: {post}")
|
|
print(f"FINAL URL: {page.url}")
|
|
# quick success heuristic
|
|
text = page.inner_text("body").lower()
|
|
for kw in ("thank", "received", "submitted", "success", "review"):
|
|
if kw in text:
|
|
print(f"SUCCESS keyword found: {kw}")
|
|
return 0
|
|
print("NO success keyword — inspect HTML manually")
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|