mgbam commited on
Commit
b511058
·
verified ·
1 Parent(s): 1036e65

Update orchestrator/client.py

Browse files
Files changed (1) hide show
  1. orchestrator/client.py +25 -0
orchestrator/client.py CHANGED
@@ -1 +1,26 @@
1
  # MCPClient implementation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # MCPClient implementation
2
+ # File: orchestrator/client.py
3
+ import requests
4
+ import uuid
5
+
6
+ class MCPClient:
7
+ """
8
+ Minimal JSON-RPC 2.0 client for MCP servers.
9
+ """
10
+ def __init__(self, base_url: str):
11
+ self.base_url = base_url.rstrip('/')
12
+
13
+ def call(self, method: str, params: dict = None):
14
+ payload = {
15
+ "jsonrpc": "2.0",
16
+ "id": str(uuid.uuid4()),
17
+ "method": method,
18
+ "params": params or {}
19
+ }
20
+ resp = requests.post(f"{self.base_url}/rpc", json=payload, timeout=30)
21
+ resp.raise_for_status()
22
+ data = resp.json()
23
+ if "error" in data:
24
+ err = data["error"]
25
+ raise RuntimeError(err.get("message", str(err)))
26
+ return data.get("result")