Skip to main content
Glama

extract_otp_code

Extract numeric OTP codes from email messages or text references for automated verification processes. Supports customizable code length parameters to match various security requirements.

Instructions

Extract a numeric OTP code from an email body or message reference.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
message_textNo
inbox_idNo
message_idNo
otp_length_minNo
otp_length_maxNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for extracting an OTP code from a message.
    async def run(
        api: ApiClient,
        message_text: str | None = None,
        inbox_id: str | None = None,
        message_id: str | None = None,
        otp_length_min: int = 4,
        otp_length_max: int = 8,
    ) -> dict[str, Any]:
        if otp_length_min < 1 or otp_length_max < otp_length_min:
            return tool_error("validation_error", 400, "otp_length_min/max are invalid")
    
        resolved_text, error, _ = await resolve_message_text(
            api=api,
            message_text=message_text,
            inbox_id=inbox_id,
            message_id=message_id,
        )
        if error:
            return error
        if not resolved_text:
            return tool_error("empty_message", 422, "Message body is empty")
    
        candidates = extract_otp_candidates(
            resolved_text,
            otp_length_min=otp_length_min,
            otp_length_max=otp_length_max,
        )
    
        return {
            "otp_code": candidates[0] if candidates else None,
            "candidates": candidates,
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full disclosure burden. While 'Extract' implies a read operation, the description fails to specify idempotency, side effects (e.g., marking emails as read), failure modes (no code found), or how it handles multiple potential codes in an inbox.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The single sentence is efficiently structured and front-loaded, but inappropriately terse for a tool with five undocumented parameters. It lacks the necessary elaboration to compensate for the zero-coverage input schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given five parameters with no schema descriptions and a likely structured output (output schema exists), the description is insufficient. It omits critical workflow context suggested by sibling tools (signup flow integration), parameter precedence rules, and error handling behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description partially compensates by mapping 'email body' to message_text and 'message reference' to inbox_id/message_id. However, it fails to explain the mutual exclusivity logic between text and IDs, the distinction between inbox_id and message_id, or the purpose of otp_length constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Extract') and resource ('numeric OTP code') and distinguishes from sibling tool 'extract_verification_link' by specifying it handles codes rather than links. However, 'message reference' is slightly ambiguous regarding whether it refers to inbox_id, message_id, or both.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance on when to use this tool versus siblings (e.g., 'extract_verification_link' for links vs codes) or prerequisites (e.g., whether 'get_latest_email' or 'wait_for_verification_email' must be called first). The relationship between providing raw text vs message references is not clarified.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/francofuji/un-correo-temporal'

If you have feedback or need assistance with the MCP directory API, please join our Discord server