wait_for_sms
Long-poll for inbound SMS after form submission. Use optional regex matching to filter messages and extract codes. Returns message body or timeout status.
Instructions
Long-poll (blocking up to timeout seconds, max 180) for the next inbound
SMS on a provisioned number. Use this right AFTER submitting a form that
triggers an SMS — call this to catch the reply.
match is an optional regex (e.g. \d{6} for a 6-digit code) — only
messages matching the pattern satisfy the wait. Any inbound message satisfies
it when match is None.
Returns the message dict (with body and auto-extracted extracted_code
when present), or {"message": null, "status": "timeout"} if no message
arrived in time.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| phone_number | Yes | ||
| timeout | No | ||
| match | No |
Implementation Reference
- agentline_mcp/server.py:132-160 (handler)The wait_for_sms tool handler function decorated with @mcp.tool(). It long-polls for an inbound SMS on a provisioned number, optionally matching a regex. Returns the message dict or timeout status.
@mcp.tool() def wait_for_sms( phone_number: str, timeout: float = DEFAULT_WAIT_TIMEOUT, match: str | None = None, ) -> dict: """Long-poll (blocking up to `timeout` seconds, max 180) for the next inbound SMS on a provisioned number. Use this right AFTER submitting a form that triggers an SMS — call this to catch the reply. `match` is an optional regex (e.g. `\\d{6}` for a 6-digit code) — only messages matching the pattern satisfy the wait. Any inbound message satisfies it when `match` is None. Returns the message dict (with `body` and auto-extracted `extracted_code` when present), or `{"message": null, "status": "timeout"}` if no message arrived in time. """ try: msg = _client_or_init().wait_for_sms( phone_number=phone_number, 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:133-133 (registration)The tool is registered via the @mcp.tool() decorator on line 132, which is the FastMCP registration mechanism.
def wait_for_sms( - agentline_mcp/server.py:58-59 (helper)Helper function _clamp_timeout clamps the timeout value between 1.0 and MAX_WAIT_TIMEOUT (180.0), used by wait_for_sms.
def _clamp_timeout(timeout: float) -> float: return max(1.0, min(float(timeout), MAX_WAIT_TIMEOUT)) - agentline_mcp/server.py:51-55 (helper)Helper _client_or_init() lazily initializes and returns the Agentline SDK client, used by wait_for_sms to call the SDK method.
def _client_or_init() -> Agentline: global _client if _client is None: _client = _build_client() return _client - agentline_mcp/server.py:26-27 (schema)Constants DEFAULT_WAIT_TIMEOUT (60.0) and MAX_WAIT_TIMEOUT (180.0) define the default and max timeout values used in wait_for_sms parameter schema.
DEFAULT_WAIT_TIMEOUT = 60.0 MAX_WAIT_TIMEOUT = 180.0