capture_code
Provision a temporary phone number to receive SMS verification codes. Wait for an incoming 2FA code (4-8 digits) and retrieve the phone number and code. Optionally keep the number by setting release_after=False.
Instructions
All-in-one 2FA capture: provision a fresh phone number, wait for an incoming SMS verification code (4-8 digits by default), then release the number. THE killer flow for signups.
Typical use: call this, take phone_number from the result and paste into
the signup form, then code will be the extracted 2FA code once it arrives.
If no code arrives in timeout seconds, code is null.
Set release_after=False if you plan to keep using the number.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area_code | No | ||
| timeout | No | ||
| release_after | No |
Implementation Reference
- agentline_mcp/server.py:163-196 (handler)The handler function that executes the 'capture_code' tool logic: provisions a phone number, waits for an SMS verification code, optionally releases the number, and returns the result.
@mcp.tool() def capture_code( area_code: str | None = None, timeout: float = DEFAULT_WAIT_TIMEOUT, release_after: bool = True, ) -> dict: """All-in-one 2FA capture: provision a fresh phone number, wait for an incoming SMS verification code (4-8 digits by default), then release the number. THE killer flow for signups. Typical use: call this, take `phone_number` from the result and paste into the signup form, then `code` will be the extracted 2FA code once it arrives. If no code arrives in `timeout` seconds, `code` is null. Set `release_after=False` if you plan to keep using the number. """ try: client = _client_or_init() number = client.provision_number(area_code=area_code) try: code = client.get_verification_code( number.phone_number, timeout=_clamp_timeout(timeout), ) return { "phone_number": number.phone_number, "code": code, "released": release_after, } finally: if release_after: client.release_number(number.phone_number) except AgentlineError as e: return {"error": str(e), "status_code": e.status_code} - agentline_mcp/server.py:163-164 (registration)The @mcp.tool() decorator registers 'capture_code' as an MCP tool on the FastMCP instance.
@mcp.tool() def capture_code( - agentline_mcp/server.py:58-59 (helper)Helper that clamps the timeout parameter to [1.0, MAX_WAIT_TIMEOUT=180.0] seconds.
def _clamp_timeout(timeout: float) -> float: return max(1.0, min(float(timeout), MAX_WAIT_TIMEOUT)) - agentline_mcp/server.py:51-55 (helper)Helper that returns a cached Agentline client instance, initializing it if needed.
def _client_or_init() -> Agentline: global _client if _client is None: _client = _build_client() return _client