-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcp_example.py
More file actions
33 lines (27 loc) · 953 Bytes
/
mcp_example.py
File metadata and controls
33 lines (27 loc) · 953 Bytes
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
#!/usr/bin/env python3
import json
import subprocess
import sys
def query_mcp(method, params=None):
"""Send a query to the MCP server and return the response"""
if params is None:
params = {}
request = {"method": method, "params": params}
process = subprocess.Popen(
[sys.executable, "mcp_server.py"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True
)
stdout, _ = process.communicate(json.dumps(request))
return json.loads(stdout.strip())
# Example usage
if __name__ == "__main__":
# Get first 3 matches
matches = query_mcp("get_matches", {"limit": 3})
print("Matches:", json.dumps(matches, indent=2))
# Get goals from first match
if matches["data"]:
match_id = matches["data"][0]["id"]
goals = query_mcp("get_goals", {"match_id": match_id})
print(f"\nGoals for match {match_id}:", json.dumps(goals, indent=2))