import asyncio
import nest_asyncio
from mcp import ClientSession
from mcp.client.sse import sse_client
nest_asyncio.apply() # Needed to run interactive python
"""
Make sure:
1. The server is running before running this script.
2. The server is configured to use SSE transport.
3. The server is listening on port 8050.
To run the server:
uv run server.py
"""
async def main():
# Connect to the server using SSE
async with sse_client("http://localhost:8000/sse") as (read_stream, write_stream):
async with ClientSession(read_stream, write_stream) as session:
# Initialize the connection
await session.initialize()
# List available tools
tools_result = await session.list_tools()
print("Available tools:")
for tool in tools_result.tools:
print(f" - {tool.name}: {tool.description}")
# Call our Weather tool
result = await session.call_tool("get_alerts", arguments={"state":"CA"})
print(f"The weather alerts are = {result.content[0].text}")
if __name__ == "__main__":
asyncio.run(main())
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ugundhar/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server