-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
107 lines (86 loc) · 3.47 KB
/
test.py
File metadata and controls
107 lines (86 loc) · 3.47 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import json
from mcp.client.sse import sse_client
from mcp import ClientSession
import asyncio
url = "http://127.0.0.1:8000/sse"
# url = "https://mcp.netmind.ai/sse/4a8e68a6490342d3b1c7fbee0ad1b508/sugar-mcp/sse?SUGAR_PK=d3c9e669cca21d6d9cc186a4d710b7127bcc84ed0184d94ee42766f8d63c8df9"
async def main():
async with sse_client(url) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
try:
response = await session.call_tool(
"get_all_tokens",
{
"limit": 2,
"offset": 0,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_token_prices",
{
"token_address": "0x4200000000000000000000000000000000000006",
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_prices",
{
"limit": 2,
"offset": 0,
"listed_only": False,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_pools",
{
"limit": 2,
"offset": 0,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_pools_for_swaps",
{
"limit": 2,
"offset": 0,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_latest_pool_epochs",
{
"offset": 0,
"limit": 10,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
response = await session.call_tool(
"get_pool_epochs",
{
"lp": "0x2722C8f9B5E2aC72D1f225f8e8c990E449ba0078",
"offset": 0,
"limit": 10,
"chain_id": "8453"
}
)
data = json.loads(response.content[0].text)
print(json.dumps(data, indent=2, ensure_ascii=False))
except Exception as e:
print(f"Error listing tools: {e}")
if __name__ == "__main__":
asyncio.run(main())