-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathclient.py
More file actions
37 lines (29 loc) · 970 Bytes
/
client.py
File metadata and controls
37 lines (29 loc) · 970 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
import asyncio
import os
from fastmcp import Client
from fastmcp.client.auth import OAuth
oauth = OAuth(
mcp_url="http://localhost:5000/mcp",
scopes=["openid"],
)
# Pass the JWT from IDCS login
token = os.getenv("TOKEN")
if token:
print("using token")
client = Client("http://localhost:5000/mcp", auth=token or oauth)
async def main():
async with client:
await client.ping()
# list available operations
tools = await client.list_tools()
print(f"Tools: {tools}")
resources = await client.list_resources()
print(f"Resources: {resources}")
prompts = await client.list_prompts()
print(f"Prompts: {prompts}")
# call list regions tool
result = await client.call_tool("list_regions", {"region": "us-ashburn-1"})
result = await client.call_tool("get_os_namespace", {"region": "us-ashburn-1"})
print(result)
if __name__ == "__main__":
asyncio.run(main())