-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmcp-cli-example.py
More file actions
40 lines (31 loc) · 1.2 KB
/
mcp-cli-example.py
File metadata and controls
40 lines (31 loc) · 1.2 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
import os
from dotenv import load_dotenv
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
load_dotenv()
# Read credentials and fail fast if missing
SMITHERY_API_KEY = os.getenv("SMITHERY_API_KEY")
if not SMITHERY_API_KEY:
raise RuntimeError(
"Missing SMITHERY_API_KEY. Set it in a .env file or export it in your shell."
)
# Construct server URL with authentication
from urllib.parse import urlencode
base_url = "https://server.smithery.ai/@supabase-community/supabase-mcp/mcp"
params = {
"api_key": SMITHERY_API_KEY,
"profile": os.getenv("SMITHERY_PROFILE", "present-vole-PSJkUx"),
}
url = f"{base_url}?{urlencode(params)}"
async def main():
# Connect to the server using HTTP client
async with streamablehttp_client(url) as (read, write, _):
async with ClientSession(read, write) as session:
# Initialize the connection
await session.initialize()
# List available tools
tools_result = await session.list_tools()
print(f"Available tools: {', '.join([t.name for t in tools_result.tools])}")
if __name__ == "__main__":
import asyncio
asyncio.run(main())