forked from naman-msft/mcp-dev-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-mcp-session.py
More file actions
49 lines (42 loc) · 1.01 KB
/
test-mcp-session.py
File metadata and controls
49 lines (42 loc) · 1.01 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
import json
import requests
# Start a session
session = requests.Session()
base_url = "http://localhost:8080/mcp"
# Initialize
init_request = {
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"protocolVersion": "1.0.0",
"capabilities": {"tools": {}},
"clientInfo": {"name": "test", "version": "1.0.0"}
},
"id": 1
}
print("Initializing...")
response = session.post(base_url, json=init_request)
print(f"Init response: {response.json()}")
# List tools
list_request = {
"jsonrpc": "2.0",
"method": "tools/list",
"params": {},
"id": 2
}
print("\nListing tools...")
response = session.post(base_url, json=list_request)
print(f"Tools response: {response.json()}")
# Call system_info
call_request = {
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "system_info",
"arguments": {}
},
"id": 3
}
print("\nCalling system_info...")
response = session.post(base_url, json=call_request)
print(f"System info: {response.json()}")