|
| 1 | +import type { PresendEmailVerifyParams, PresendEmailVerifyResponse } from '@/tools/presend/types' |
| 2 | +import type { ToolConfig } from '@/tools/types' |
| 3 | + |
| 4 | +export const emailVerifyTool: ToolConfig<PresendEmailVerifyParams, PresendEmailVerifyResponse> = { |
| 5 | + id: 'presend_email_verify', |
| 6 | + name: 'Presend Email Verify', |
| 7 | + description: |
| 8 | + 'Free, no-signup, no-key single-address email verification: syntax, MX record, disposable-domain, and role-account checks in one call.', |
| 9 | + version: '1.0.0', |
| 10 | + |
| 11 | + params: { |
| 12 | + email: { |
| 13 | + type: 'string', |
| 14 | + required: true, |
| 15 | + visibility: 'user-or-llm', |
| 16 | + description: 'The email address to verify', |
| 17 | + }, |
| 18 | + }, |
| 19 | + |
| 20 | + request: { |
| 21 | + url: (params) => { |
| 22 | + const url = new URL('https://presend.pages.dev/api/email-verify') |
| 23 | + url.searchParams.append('email', params.email) |
| 24 | + |
| 25 | + return url.toString() |
| 26 | + }, |
| 27 | + method: 'GET', |
| 28 | + headers: () => ({ |
| 29 | + 'Content-Type': 'application/json', |
| 30 | + }), |
| 31 | + }, |
| 32 | + |
| 33 | + transformResponse: async (response: Response) => { |
| 34 | + const data = await response.json() |
| 35 | + |
| 36 | + return { |
| 37 | + success: true, |
| 38 | + output: { |
| 39 | + email: data?.email ?? '', |
| 40 | + valid: data?.valid ?? false, |
| 41 | + syntaxValid: data?.syntax_valid ?? false, |
| 42 | + domain: data?.domain ?? '', |
| 43 | + mxFound: data?.has_mx ?? false, |
| 44 | + mxCount: data?.mx_count ?? 0, |
| 45 | + disposable: data?.disposable ?? false, |
| 46 | + roleAccount: data?.role_account ?? false, |
| 47 | + reason: data?.reason ?? '', |
| 48 | + }, |
| 49 | + } |
| 50 | + }, |
| 51 | + |
| 52 | + outputs: { |
| 53 | + email: { |
| 54 | + type: 'string', |
| 55 | + description: 'The verified email address', |
| 56 | + }, |
| 57 | + valid: { |
| 58 | + type: 'boolean', |
| 59 | + description: 'Whether the email address is valid overall', |
| 60 | + }, |
| 61 | + syntaxValid: { |
| 62 | + type: 'boolean', |
| 63 | + description: 'Whether the email address is correctly formatted (RFC syntax)', |
| 64 | + }, |
| 65 | + domain: { |
| 66 | + type: 'string', |
| 67 | + description: 'The domain part of the email address', |
| 68 | + }, |
| 69 | + mxFound: { |
| 70 | + type: 'boolean', |
| 71 | + description: "Whether the domain's MX records were found", |
| 72 | + }, |
| 73 | + mxCount: { |
| 74 | + type: 'number', |
| 75 | + description: 'Number of MX records found for the domain', |
| 76 | + }, |
| 77 | + disposable: { |
| 78 | + type: 'boolean', |
| 79 | + description: 'Whether the email uses a disposable/temporary domain', |
| 80 | + }, |
| 81 | + roleAccount: { |
| 82 | + type: 'boolean', |
| 83 | + description: 'Whether the address is a role account (e.g. info@, support@)', |
| 84 | + }, |
| 85 | + reason: { |
| 86 | + type: 'string', |
| 87 | + description: 'Explanation when the address is invalid, otherwise null', |
| 88 | + }, |
| 89 | + }, |
| 90 | +} |
0 commit comments