Spaces:
Sleeping
Sleeping
Download orchestrator/client.py from mgbam/MCP_Research: direct link, hf CLI and curl.
- Browser
- Download file 763 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Research/resolve/7ed183c1d2179e355ce33d1e12760a70b7dcf03d/orchestrator/client.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Research@7ed183c1d2179e355ce33d1e12760a70b7dcf03d/orchestrator/client.py
-
curl -L -o client.py https://huggingface.co/spaces/mgbam/MCP_Research/resolve/7ed183c1d2179e355ce33d1e12760a70b7dcf03d/orchestrator/client.py
763 Bytes
| # MCPClient implementation | |
| # File: orchestrator/client.py | |
| import requests | |
| import uuid | |
| class MCPClient: | |
| """ | |
| Minimal JSON-RPC 2.0 client for MCP servers. | |
| """ | |
| def __init__(self, base_url: str): | |
| self.base_url = base_url.rstrip('/') | |
| def call(self, method: str, params: dict = None): | |
| payload = { | |
| "jsonrpc": "2.0", | |
| "id": str(uuid.uuid4()), | |
| "method": method, | |
| "params": params or {} | |
| } | |
| resp = requests.post(f"{self.base_url}/rpc", json=payload, timeout=30) | |
| resp.raise_for_status() | |
| data = resp.json() | |
| if "error" in data: | |
| err = data["error"] | |
| raise RuntimeError(err.get("message", str(err))) | |
| return data.get("result") | |