add
测试mcp基座
This commit is contained in:
1 parent
c0966ad334
commit
1afcc10a61
6 files changed
+489
-96
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import socket
|
||||
import json
|
||||
|
||||
def test_fake_llm_zoom():
|
||||
print("=== 模拟 LLM 发起缩放指令测试 ===")
|
||||
|
||||
try:
|
||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
client.connect(("127.0.0.1", 8080))
|
||||
|
||||
# 伪造大模型生成的 tool_call 报文
|
||||
req = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 999,
|
||||
"method": "tools/call",
|
||||
"params": {
|
||||
"name": "zoom_window_normalized",
|
||||
"arguments": {
|
||||
"x1": 0.4,
|
||||
"y1": 0.4,
|
||||
"x2": 0.6,
|
||||
"y2": 0.6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(f"\n[发送] 请求参数:\n{json.dumps(req['params'], indent=2)}")
|
||||
client.sendall(json.dumps(req).encode('utf-8'))
|
||||
|
||||
response_data = client.recv(4096)
|
||||
|
||||
print(f"\n[接收] CAD 基座返回:")
|
||||
print(json.dumps(json.loads(response_data.decode('utf-8')), indent=2, ensure_ascii=False))
|
||||
|
||||
client.close()
|
||||
|
||||
except Exception as e:
|
||||
print(f"测试失败: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_fake_llm_zoom()
|
||||
Reference in new issue
Block a user