Skip to main content
Glama
mkotsollaris

kwrds.ai MCP Server

by mkotsollaris
http_client.py1.92 kB
""" HTTP client utility for making API requests """ import requests from typing import Dict, Any, Optional def make_api_request(url: str, headers: Dict[str, str], data: Optional[Dict[str, Any]] = None, params: Optional[Dict[str, Any]] = None, method: str = "POST") -> Dict[str, Any]: """Make HTTP API requests with proper error handling""" try: # Convert any non-string values in data to strings to avoid header issues if data: data = convert_params_to_strings(data) if params: params = convert_params_to_strings(params) if method.upper() == 'GET': response = requests.get(url, headers=headers, params=params, timeout=30) else: response = requests.post(url, headers=headers, json=data, timeout=30) if response.status_code == 200: result = response.json() return result else: error_text = response.text raise Exception(f"API request failed with status {response.status_code}: {error_text}") except requests.RequestException as e: raise Exception(f"Request failed: {str(e)}") except Exception as e: raise Exception(f"Error making API request: {str(e)}") def convert_params_to_strings(params: Dict[str, Any]) -> Dict[str, Any]: """Convert all parameter values to strings to avoid header type issues""" converted = {} for key, value in params.items(): if isinstance(value, (int, float)): converted[key] = str(value) elif isinstance(value, list): # Convert lists to comma-separated strings converted[key] = ','.join(str(item) for item in value) elif isinstance(value, bool): converted[key] = str(value).lower() else: converted[key] = str(value) if value is not None else "" return converted

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/mkotsollaris/kwrds_ai_mcp'

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