composio-autoreg: browser-driven WorkOS AuthKit farm for ck_ consumer keys
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify a Composio consumer key (ck_...) against the MCP endpoint.
|
||||
|
||||
Usage:
|
||||
python verify_key.py ck_xxxx
|
||||
python verify_key.py --bank bank/accounts.jsonl # verify every account
|
||||
|
||||
Exit code 0 when at least one key answered with a valid MCP initialize.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
import requests
|
||||
|
||||
MCP_URL = "https://connect.composio.dev/mcp"
|
||||
INIT = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "initialize",
|
||||
"params": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {},
|
||||
"clientInfo": {"name": "verify", "version": "1"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def check(key, timeout=30):
|
||||
h = {
|
||||
"content-type": "application/json",
|
||||
"accept": "application/json, text/event-stream",
|
||||
"x-consumer-api-key": key,
|
||||
}
|
||||
try:
|
||||
r = requests.post(MCP_URL, json=INIT, headers=h, timeout=timeout)
|
||||
except Exception as e:
|
||||
return False, f"err {e}"
|
||||
body = r.text or ""
|
||||
if r.status_code == 200 and "serverInfo" in body:
|
||||
m = re.search(r'"name":"([^"]+)"', body)
|
||||
return True, f"200 {m.group(1) if m else 'ok'}"
|
||||
return False, f"{r.status_code} {body[:120]}"
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("key", nargs="?")
|
||||
ap.add_argument("--bank")
|
||||
a = ap.parse_args()
|
||||
keys = []
|
||||
if a.key:
|
||||
keys.append((None, a.key))
|
||||
if a.bank:
|
||||
for line in open(a.bank, encoding="utf-8"):
|
||||
line = line.strip()
|
||||
if not line:
|
||||
continue
|
||||
rec = json.loads(line)
|
||||
if rec.get("api_key"):
|
||||
keys.append((rec.get("email"), rec["api_key"]))
|
||||
if not keys:
|
||||
ap.error("pass a key or --bank")
|
||||
alive = 0
|
||||
for mail, key in keys:
|
||||
ok, info = check(key)
|
||||
alive += 1 if ok else 0
|
||||
print(("OK " if ok else "DEAD "), (mail or "")[:40], key[:10] + "..." + key[-4:], info)
|
||||
print(f"alive {alive}/{len(keys)}")
|
||||
sys.exit(0 if alive else 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user