-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote_test_client.py
More file actions
54 lines (46 loc) · 1.32 KB
/
remote_test_client.py
File metadata and controls
54 lines (46 loc) · 1.32 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import json
import subprocess
import sys
def main():
"""
A test client that executes the MCP server from a git repository using uvx.
"""
if len(sys.argv) != 3:
print("Usage: python remote_test_client.py <llm_name> \"<prompt>\"")
sys.exit(1)
llm_name = sys.argv[1]
prompt = sys.argv[2]
request = {
"jsonrpc": "2.0",
"method": "ask",
"params": [llm_name, prompt],
"id": 1,
}
request_str = json.dumps(request)
command = [
"uvx",
"--from",
"git+https://github.com/joubertb/mcp-askllm",
"mcp-askllm",
request_str,
]
try:
print(f"Running command: {' '.join(command)}")
result = subprocess.run(
command,
capture_output=True,
text=True,
check=True,
)
print(f"Received response: {result.stdout.strip()}")
if result.stderr:
print(f"Server errors:\n{result.stderr}")
except subprocess.CalledProcessError as e:
print(f"Error running command: {e}")
print(f"Stderr: {e.stderr}")
except FileNotFoundError:
print("Error: 'uvx' not found. Make sure it is installed and in your PATH.")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
main()