forked from Mvp2o-ai/mcp-ide-bridge
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_send.py
More file actions
44 lines (39 loc) · 1.33 KB
/
test_send.py
File metadata and controls
44 lines (39 loc) · 1.33 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
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def main():
# Connect to server
streams_context = streamablehttp_client(
url="http://localhost:8111/mcp",
headers={},
)
read_stream, write_stream, _ = await streams_context.__aenter__()
# Create session
session_context = ClientSession(read_stream, write_stream)
session = await session_context.__aenter__()
await session.initialize()
try:
# Send message
response = await session.call_tool(
"send_message_without_waiting",
{
"sender_id": "test_client",
"recipients": [
{
"id": "milesdyson",
"message": "Test message from test_client - please acknowledge if you receive this!"
}
],
"recipients_config": {
"my_sender_id": "test_client",
"my_name": "Test Client"
}
}
)
print("Message sent:", response)
finally:
# Cleanup
await session_context.__aexit__(None, None, None)
await streams_context.__aexit__(None, None, None)
if __name__ == "__main__":
asyncio.run(main())