wait_for_email
Long-poll for inbound email on a provisioned address. Trigger after sending an email (e.g., signup verification). Optionally match body text with regex. Returns subject, body_text, extracted_code on match, or timeout status.
Instructions
Long-poll (blocking up to timeout seconds, max 180) for the next
inbound email on a provisioned address. Use right after triggering an email
(e.g. a 'check your email' signup step).
match is an optional regex run against the message body. Returns the
message dict on match (includes subject, body_text, extracted_code),
or {"message": null, "status": "timeout"} on timeout.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| email_address | Yes | ||
| timeout | No | ||
| match | No |
Implementation Reference
- agentline_mcp/server.py:328-352 (handler)The `wait_for_email` tool handler — decorated with @mcp.tool(), long-polls for the next inbound email on a provisioned address. Accepts `email_address`, `timeout`, and optional `match` regex. Calls the Agentline SDK's `wait_for_email()`, returns message dict or timeout.
@mcp.tool() def wait_for_email( email_address: str, timeout: float = DEFAULT_WAIT_TIMEOUT, match: str | None = None, ) -> dict: """Long-poll (blocking up to `timeout` seconds, max 180) for the next inbound email on a provisioned address. Use right after triggering an email (e.g. a 'check your email' signup step). `match` is an optional regex run against the message body. Returns the message dict on match (includes `subject`, `body_text`, `extracted_code`), or `{"message": null, "status": "timeout"}` on timeout. """ try: msg = _client_or_init().wait_for_email( email_address=email_address, timeout=_clamp_timeout(timeout), match=match, ) if msg is None: return {"message": None, "status": "timeout"} return {"message": asdict(msg), "status": "received"} except AgentlineError as e: return {"error": str(e), "status_code": e.status_code} - agentline_mcp/server.py:328-329 (registration)Registration of `wait_for_email` as an MCP tool via the `@mcp.tool()` decorator on line 328.
@mcp.tool() def wait_for_email( - agentline_mcp/server.py:329-333 (schema)The function signature defines the input schema: `email_address: str`, `timeout: float` (default 60.0), `match: str | None`. Return type is `dict`.
def wait_for_email( email_address: str, timeout: float = DEFAULT_WAIT_TIMEOUT, match: str | None = None, ) -> dict: - agentline_mcp/server.py:58-59 (helper)Helper function `_clamp_timeout` used to clamp the timeout parameter to [1.0, MAX_WAIT_TIMEOUT=180.0].
def _clamp_timeout(timeout: float) -> float: return max(1.0, min(float(timeout), MAX_WAIT_TIMEOUT)) - agentline_mcp/server.py:26-27 (helper)Constants `DEFAULT_WAIT_TIMEOUT` (60.0) and `MAX_WAIT_TIMEOUT` (180.0) used by the `wait_for_email` tool.
DEFAULT_WAIT_TIMEOUT = 60.0 MAX_WAIT_TIMEOUT = 180.0