To produce one IP:port per line from ProxyHub MCP, start with the complete JSON-RPC response, not a copied chat text block.

  1. Call list_proxies through your MCP client with type set to http.
  2. Save the complete response as mcp-response.json.
  3. Save the following standard-library converter as mcp-to-file.py beside that response.
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")

Run it in that directory:

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

Check the printed count and http-proxies.txt. The original response is retained. JSON-RPC errors and tool-level isError responses raise errors; a successful response with no matches writes an empty file and reports zero. The tool limit is up to 100 per call, so the output represents that returned selection, not necessarily the whole HTTP proxy list.

The converter accepts only rows reported as http and checks IPv4 syntax and port range, matching the current collector's IPv4 format. For another protocol, preserve that information or use a separate file; a plain mixed IP:port file cannot tell the receiving client which handshake to use.

An exported row is still data. updated_at records the stored data-update time, not a live request from your network. Test chosen endpoints with a bounded HTTP-proxy request against the destination you need. If the MCP call failed, investigate data retrieval; if a later request through an exported endpoint failed, investigate that separate proxy connection.

متعلقہ مضامین