verify_email
Check email address validity using the 2ip.me API to confirm existence and deliverability before sending messages.
Instructions
Verify an email address using the 2ip.me API.
Args:
email (str): The email address to verify
Returns:
str: "true" or "false" indicating if the email is valid
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Yes |
Implementation Reference
- src/email_checker/tools.py:12-23 (handler)MCP tool handler for 'verify_email', decorated with @mcp.tool(). Delegates to EmailValidatorAPI.verify_email. Includes input/output schema via type hints and docstring.@mcp.tool() async def verify_email(email: str) -> str: """ Verify an email address using the 2ip.me API. Args: email (str): The email address to verify Returns: str: "true" or "false" indicating if the email is valid """ return await api.verify_email(email)
- Core helper method implementing the email verification logic by calling make_request and handling the result.async def verify_email(self, email: str) -> str: """Verify an email address.""" result = await self.make_request(email) if result is None: return "Error: Unable to verify email" return result
- Supporting utility that makes the HTTP request to the 2ip.me API endpoint for email verification.async def make_request(self, email: str) -> str | None: """Make a request to the 2ip.me API with proper error handling.""" url = f"{self.api_base}?email={email}" async with httpx.AsyncClient() as client: try: response = await client.get(url, timeout=30.0) response.raise_for_status() return response.text.strip() except Exception as e: logger.error(f"API request failed: {str(e)}") return None