Spaces:
Running
Running
File size: 747 Bytes
b511058 d9b8a18 b511058 d9b8a18 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 {}
}
response = requests.post(f"{self.base_url}/rpc", json=payload, timeout=30)
response.raise_for_status()
data = response.json()
if 'error' in data:
err = data['error']
raise RuntimeError(err.get('message', str(err)))
return data.get('result') |