Files
dguiducci 7f6477dd68 Aggiunto connector Context7 (mcp_remote)
- URL: https://mcp.context7.com/mcp, trasporto streamable-http
- Auth: none (endpoint pubblico, free tier)
- Verify: MCP initialize probe (testato )
- Icone SVG dal logo ufficiale Context7

Inoltre:
- Copiata docs/connector.manifest_guide.md da skald-circle/blueprint/
- Riferimento alla guida in SKALD.md
2026-07-22 21:40:12 +01:00

67 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""Verify connectivity to Context7's hosted MCP server.
Sends a lightweight JSON-RPC initialize to https://mcp.context7.com/mcp
and checks for a successful response. No API key required — Context7's
remote MCP endpoint works on the free tier without authentication.
Prints a single JSON object on stdout:
{"ok": true, "message": "Context7 MCP endpoint is reachable"}
{"ok": false, "message": "Context7 MCP endpoint is unreachable: <reason>"}
Exit code is 0 on success, 1 on any failure.
stdlib only (urllib).
"""
import json
import sys
import urllib.error
import urllib.request
def _result(ok, message):
print(json.dumps({"ok": ok, "message": message}))
sys.exit(0 if ok else 1)
def main():
url = "https://mcp.context7.com/mcp"
body = json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-03-26",
"capabilities": {},
"clientInfo": {"name": "skald-verify", "version": "1.0.0"},
},
}).encode("utf-8")
req = urllib.request.Request(
url,
data=body,
headers={
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream",
},
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=15) as resp:
data = resp.read().decode("utf-8")
if 200 <= resp.status < 300:
# Check for a valid JSON-RPC result in the SSE event stream
if '"result"' in data and '"serverInfo"' in data:
_result(True, "Context7 MCP endpoint is reachable")
_result(False, f"Context7 returned unexpected response: {data[:200]}")
_result(False, f"Context7 returned HTTP {resp.status}")
except urllib.error.HTTPError as e:
_result(False, f"Context7 returned HTTP {e.code}: {e.reason}")
except Exception as e:
_result(False, f"Context7 MCP endpoint is unreachable: {e}")
if __name__ == "__main__":
main()