verify_email
Validate email addresses using AtData's SafeToSend API to identify invalid or high-risk emails, improving deliverability, engagement, and campaign effectiveness.
Instructions
Verify an email address using AtData's SafeToSend API.
This tool verifies email addresses to filter out invalid and high-risk ones,
which results in higher open rates, clicks, and conversions.
Args:
email: The email address to verify
api_key: AtData API key (if not provided, will try to get from ATDATA_API_KEY env var)
Returns:
Dictionary containing the verification results including:
- email: The email address that was verified
- status: The verification status
- deliverable: Whether the email is deliverable
- risk_level: Risk assessment of the email
- additional verification details
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | ||
| Yes |
Implementation Reference
- server.py:17-105 (handler)The handler function for the 'verify_email' tool. It is decorated with @mcp.tool() for registration and implements the core logic to verify an email using the AtData SafeToSend API, handling API requests, errors, and responses.@mcp.tool() def verify_email(email: str, api_key: Optional[str] = None) -> Dict[str, Any]: """ Verify an email address using AtData's SafeToSend API. This tool verifies email addresses to filter out invalid and high-risk ones, which results in higher open rates, clicks, and conversions. Args: email: The email address to verify api_key: AtData API key (if not provided, will try to get from ATDATA_API_KEY env var) Returns: Dictionary containing the verification results including: - email: The email address that was verified - status: The verification status - deliverable: Whether the email is deliverable - risk_level: Risk assessment of the email - additional verification details """ # Get API key from parameter or environment variable if api_key is None: api_key = os.getenv("ATDATA_API_KEY") if not api_key: return { "error": "API key is required. Provide it as a parameter or set ATDATA_API_KEY environment variable.", "email": email, } # AtData SafeToSend API endpoint url = "https://api.atdata.com/v5/ev" # Set up headers headers = {"Accept": "application/json", "User-Agent": "AtData-MCP-Server/1.0"} # Set up parameters params = {"email": email, "api_key": api_key} try: # Make the API request response = requests.get(url, headers=headers, params=params, timeout=30) # Check if request was successful if response.status_code == 200: result = response.json() return {"success": True, "email": email, "verification_result": result} elif response.status_code == 401: return { "error": "Authentication failed. Please check your API key.", "email": email, "status_code": response.status_code, } elif response.status_code == 400: return { "error": "Bad request. Please check the email format.", "email": email, "status_code": response.status_code, "details": response.text, } elif response.status_code == 429: return { "error": "Rate limit exceeded. Please try again later.", "email": email, "status_code": response.status_code, } else: return { "error": f"API request failed with status code {response.status_code}", "email": email, "status_code": response.status_code, "details": response.text, } except requests.exceptions.Timeout: return { "error": "Request timeout. The API did not respond within 30 seconds.", "email": email, } except requests.exceptions.ConnectionError: return { "error": "Connection error. Unable to reach the AtData API.", "email": email, } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}", "email": email} except Exception as e: return {"error": f"Unexpected error: {str(e)}", "email": email}
- server.py:18-36 (schema)The function signature with type hints and docstring define the input schema (parameters: email str, optional api_key str) and output schema (Dict[str, Any] with described fields). This is used by FastMCP to generate the tool schema.def verify_email(email: str, api_key: Optional[str] = None) -> Dict[str, Any]: """ Verify an email address using AtData's SafeToSend API. This tool verifies email addresses to filter out invalid and high-risk ones, which results in higher open rates, clicks, and conversions. Args: email: The email address to verify api_key: AtData API key (if not provided, will try to get from ATDATA_API_KEY env var) Returns: Dictionary containing the verification results including: - email: The email address that was verified - status: The verification status - deliverable: Whether the email is deliverable - risk_level: Risk assessment of the email - additional verification details """
- server.py:17-17 (registration)The @mcp.tool() decorator registers the verify_email function as an MCP tool.@mcp.tool()
- server.py:138-138 (helper)The verify_email function is used as a helper inside the batch_verify_emails tool.result = verify_email(email, api_key)