Skip to main content
Glama

mxHERO Mail2Cloud MCP

search.py1.61 kB
import requests import datetime import logging def query(query_string: str, api_host: str, token: str, context=None) -> str: """ Python equivalent of the Go query function. Args: query_string: The query string to send to the API api_host: The base URL of the API token: The authentication token context: Optional context (not used in this implementation) Returns: The response body as a string Raises: Exception: If the request fails or returns a non-200 status code """ # Construct the endpoint URL endpoint_url = f"{api_host}/gpt/email/query" # Add query parameters params = { 'q': query_string, 't': datetime.datetime.now().astimezone().isoformat() } # Add Authorization header headers = { 'Authorization': f'Bearer {token}' } try: # Perform the request response = requests.get(endpoint_url, params=params, headers=headers) # Check status code if response.status_code != 200: error_msg = f"Unexpected status code: {response.status_code}" logging.error(error_msg) raise Exception(error_msg) # Return the response body return response.text except requests.RequestException as e: error_msg = f"Failed to execute request: {str(e)}" logging.error(error_msg) raise Exception(error_msg) except Exception as e: error_msg = f"Error: {str(e)}" logging.error(error_msg) raise

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/mxaiorg/mxmcp-py'

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