mgbam's picture
Update orchestrator/client.py
d9b8a18 verified
raw
history blame
747 Bytes
# 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')