-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-mcp-server-unity.py
More file actions
40 lines (35 loc) · 904 Bytes
/
Copy pathtest-mcp-server-unity.py
File metadata and controls
40 lines (35 loc) · 904 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
34
35
36
37
38
39
40
import subprocess
import json
# Obre el procés (igual que abans)
proc = subprocess.Popen(
"unity-mcp", # or ["unity-mcp"] if not using shell=True
cwd="C:\\Projects\\Unity-MCP-Server", # Adjust as needed
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
# Preparar la crida a l'eina unity_list_assets
comanda = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "unity_list_assets",
"arguments": {
"path": "Assets",
"pattern": "*.cs"
}
},
"id": 2
}
# Envia la comanda
missatge = json.dumps(comanda) + "\n"
proc.stdin.write(missatge.encode())
proc.stdin.flush()
# Llegeix la resposta
resposta = proc.stdout.readline()
if resposta:
print("Resposta:", json.loads(resposta.decode()))
else:
error = proc.stderr.read()
print("Error:", error.decode())
proc.terminate()