Skip to content

howseen-ai/claude-motion-design / skill/motion-design

motion-design

Verified

scripts/mcp21_client.py

View on GitHub
"""Minimal MCP client for 21st.dev (streamable HTTP + x-api-key). usage: mcp21.py tools | mcp21.py call <tool> '<json>'"""
import json, os, sys, urllib.request
KEY = os.environ.get("API_KEY_21ST") or open(os.path.expanduser("~/.config/21st.key")).read().strip()
URL = "https://21st.dev/api/mcp"
SID = None


def rpc(method, params=None, id_=1):
    global SID
    body = {"jsonrpc": "2.0", "method": method}
    if id_ is not None: body["id"] = id_
    if params is not None: body["params"] = params
    h = {"Content-Type": "application/json", "Accept": "application/json, text/event-stream", "x-api-key": KEY, "User-Agent": "claude-code-mcp-client/1.0"}
    if SID: h["Mcp-Session-Id"] = SID
    try:
        r = urllib.request.urlopen(urllib.request.Request(URL, data=json.dumps(body).encode(), headers=h), timeout=90)
    except urllib.error.HTTPError as e:
        print("HTTP", e.code, e.read().decode()[:600]); sys.exit(1)
    SID = r.headers.get("Mcp-Session-Id") or SID
    raw = r.read().decode()
    if not raw.strip(): return None
    if raw.lstrip().startswith("{"): return json.loads(raw)
    for line in raw.splitlines():
        if line.startswith("data:"):
            d = json.loads(line[5:].strip())
            if d.get("id") == id_: return d
    return raw


rpc("initialize", {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "claude-code-raph", "version": "1"}})
rpc("notifications/initialized", None, None)
if sys.argv[1] == "tools":
    for t in rpc("tools/list", {}, 2)["result"]["tools"]:
        props = list((t.get("inputSchema") or {}).get("properties", {}).keys())
        print(f"- {t['name']}({', '.join(props)}): {(t.get('description') or '')[:260]}")
else:
    res = rpc("tools/call", {"name": sys.argv[2], "arguments": json.loads(sys.argv[3] if len(sys.argv) > 3 else "{}")}, 3)
    r = res.get("result", res) if isinstance(res, dict) else res
    if isinstance(r, dict) and "content" in r:
        for c in r["content"]: print(c.get("text", c)[:12000] if isinstance(c.get("text"), str) else c)
    else: print(json.dumps(r, ensure_ascii=False)[:12000])
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall