ProxyHub MCPમાંથી દરેક લીટીમાં એક IP:port બનાવવા માટે આખા JSON-RPC જવાબથી શરૂ કરો, ચેટમાંથી કૉપી કરેલા લખાણના બ્લોકથી નહીં.

  1. MCP ક્લાયન્ટ વડે list_proxies કૉલ કરો અને typeને http પર સેટ કરો.
  2. આખો જવાબ mcp-response.json તરીકે સાચવો.
  3. નીચે આપેલો સ્ટાન્ડર્ડ લાઇબ્રેરી વાપરતો કન્વર્ટર જવાબની બાજુમાં mcp-to-file.py તરીકે સાચવો.
import json
from ipaddress import IPv4Address
from pathlib import Path

reply = json.loads(
    Path("mcp-response.json").read_text(encoding="utf-8")
)
if "error" in reply:
    raise RuntimeError("MCP returned a JSON-RPC error")

result = reply["result"]
if result.get("isError"):
    raise RuntimeError("The proxy tool reported an error")

data = result["structuredContent"]
endpoints = []
seen = set()

for row in data["proxies"]:
    if row["type"] != "http":
        continue
    host = str(IPv4Address(row["ip"]))
    port = row["port"]
    if type(port) is not int or not 1 <= port <= 65535:
        raise ValueError("Invalid proxy port")
    endpoint = f"{host}:{port}"
    if endpoint not in seen:
        seen.add(endpoint)
        endpoints.append(endpoint)

text = "\n".join(endpoints)
Path("http-proxies.txt").write_text(
    text + ("\n" if text else ""),
    encoding="utf-8",
)
print(f"Saved {len(endpoints)} HTTP endpoints")

તે જ ડિરેક્ટરીમાં ચલાવો:

uv run --no-project python mcp-to-file.py

છપાયેલી સંખ્યા અને http-proxies.txt તપાસો. મૂળ જવાબ જળવાય છે. JSON-RPC ભૂલો અને ટૂલ-સ્તરના isError જવાબ ભૂલ ઉઠાવે છે; મેચ વગરનો સફળ જવાબ ખાલી ફાઇલ લખે છે અને શૂન્ય બતાવે છે. ટૂલની મર્યાદા દરેક કૉલમાં વધુમાં વધુ 100 એન્ટ્રી છે, તેથી આઉટપુટ પાછી મળેલી પસંદગી છે, જરૂરી નથી કે આખી HTTP પ્રોક્સી યાદી હોય.

કન્વર્ટર ફક્ત http તરીકે જણાવેલી પંક્તિ લે છે અને હાલના કલેક્ટરના IPv4 ફૉર્મેટને અનુરૂપ IPv4 રચના તથા પોર્ટ રેન્જ તપાસે છે. બીજા પ્રોટોકોલ માટે તે માહિતી સાચવો અથવા અલગ ફાઇલ વાપરો; માત્ર મિશ્ર IP:port ફાઇલ મેળવનારા ક્લાયન્ટને કયું હેન્ડશેક વાપરવું તે કહી શકતી નથી.

નિકાસ કરેલી પંક્તિ હજી ડેટા જ છે. updated_at સંગ્રહિત ડેટા અપડેટનો સમય નોંધે છે, તમારા નેટવર્કમાંથી જીવંત વિનંતી નહીં. પસંદ કરેલા એન્ડપોઇન્ટને જરૂરી ગંતવ્ય પર મર્યાદિત HTTP પ્રોક્સી વિનંતી વડે તપાસો. MCP કૉલ નિષ્ફળ થાય તો ડેટા મેળવવાનું તપાસો; પછી નિકાસ કરેલા એન્ડપોઇન્ટથી વિનંતી નિષ્ફળ થાય તો તે અલગ પ્રોક્સી જોડાણ તપાસો.

સંબંધિત લેખો