Skip to main content
Glama
test_api.py1.65 kB
import requests import json import sys # Base URL of the API BASE_URL = "http://localhost:8000" def test_health(): """Test the health check endpoint""" response = requests.get(f"{BASE_URL}/health") print(f"Health check: {response.status_code}") print(response.json()) return response.status_code == 200 def test_create_client(): """Test creating a client""" data = { "cookie": "your_cookie_here", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36", "timeout": 10 } response = requests.post(f"{BASE_URL}/clients", json=data) print(f"Create client: {response.status_code}") print(response.json()) return response.status_code == 200 def test_list_clients(): """Test listing clients""" response = requests.get(f"{BASE_URL}/clients") print(f"List clients: {response.status_code}") print(response.json()) return response.status_code == 200 def main(): """Run all tests""" tests = [ test_health, test_create_client, test_list_clients ] success = True for test in tests: try: result = test() if not result: success = False print(f"Test {test.__name__} failed") except Exception as e: success = False print(f"Test {test.__name__} raised an exception: {e}") if success: print("All tests passed!") return 0 else: print("Some tests failed!") return 1 if __name__ == "__main__": sys.exit(main())

Latest Blog Posts

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/proerror77/xhs_mcp_agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server