# Python 3. Set ANTHROPIC_API_KEY, ANTHROPIC_MODEL and QANUN_ACCESS_TOKEN privately.
import json, os, urllib.request
payload = {
    "model": os.environ["ANTHROPIC_MODEL"], "max_tokens": 1200,
    "messages": [{"role": "user", "content": "Find Health Care Commission legislation. Preserve source links and coverage limitations."}],
    "mcp_servers": [{"type": "url", "name": "qanun_maps",
                     "url": "https://www.jusnrem.legal/mcp",
                     "authorization_token": os.environ["QANUN_ACCESS_TOKEN"]}],
    "tools": [{"type": "mcp_toolset", "mcp_server_name": "qanun_maps",
               "default_config": {"enabled": False},
               "configs": {"find_legislation": {"enabled": True}}}]
}
request = urllib.request.Request("https://api.anthropic.com/v1/messages",
    data=json.dumps(payload).encode(), headers={"Content-Type": "application/json",
    "x-api-key": os.environ["ANTHROPIC_API_KEY"], "anthropic-version": "2023-06-01",
    "anthropic-beta": "mcp-client-2025-11-20"})
with urllib.request.urlopen(request, timeout=90) as response:
    print(response.read().decode())

