Skip to main content
Glama
hofill
by hofill

wait_for_request

Poll for new HTTP, DNS, SMTP, or TCP requests until timeout to capture and inspect incoming network traffic.

Instructions

Poll for a new request until timeout.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
request_typeNo
timeout_secondsNo
poll_interval_secondsNo
include_rawNo
include_bodyNo
max_bytesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of wait_for_request in RequestrepoMCPService class. This method polls for new requests until timeout, tracking seen request IDs and returning the most recent matching request or timeout status.
    def wait_for_request(
        self,
        *,
        request_type: RequestType | None = None,
        timeout_seconds: int | None = None,
        poll_interval_seconds: float = 1.0,
        include_raw: bool = False,
        include_body: bool = False,
        max_bytes: int | None = None,
    ) -> dict[str, Any]:
        if poll_interval_seconds <= 0:
            raise ValueError("poll_interval_seconds must be > 0.")
    
        resolved_timeout = self.config.default_timeout_seconds if timeout_seconds is None else timeout_seconds
        if resolved_timeout < 0:
            raise ValueError("timeout_seconds must be >= 0.")
    
        resolved_max_bytes = self._resolved_max_bytes(max_bytes)
        client = self._client()
        deadline = time.monotonic() + resolved_timeout
        seen_ids = {request.id for request in client.list_requests(limit=100, offset=0)}
    
        while time.monotonic() <= deadline:
            requests = client.list_requests(limit=100, offset=0)
            new_requests = [request for request in requests if request.id not in seen_ids]
            seen_ids.update(request.id for request in requests)
    
            if request_type is not None:
                new_requests = [request for request in new_requests if request.type == request_type]
    
            if new_requests:
                selected = max(new_requests, key=lambda request: request.date)
                return {
                    "found": True,
                    "timeout": False,
                    "request_type": request_type,
                    "request": serialize_request(
                        selected,
                        include_raw=include_raw,
                        include_body=include_body,
                        max_bytes=resolved_max_bytes,
                    ),
                }
    
            sleep_for = min(poll_interval_seconds, max(0.0, deadline - time.monotonic()))
            if sleep_for <= 0:
                break
            time.sleep(sleep_for)
    
        return {
            "found": False,
            "timeout": True,
            "request_type": request_type,
            "request": None,
        }
  • MCP tool registration using @mcp.tool() decorator in create_mcp_server function. Exposes wait_for_request as an MCP tool with default parameter values and delegates to the service method.
    @mcp.tool()
    def wait_for_request(
        request_type: RequestType | None = None,
        timeout_seconds: int = 30,
        poll_interval_seconds: float = 1.0,
        include_raw: bool = False,
        include_body: bool = False,
        max_bytes: int = 65536,
    ) -> dict[str, Any]:
        """Poll for a new request until timeout."""
        return resolved_service.wait_for_request(
            request_type=request_type,
            timeout_seconds=timeout_seconds,
            poll_interval_seconds=poll_interval_seconds,
            include_raw=include_raw,
            include_body=include_body,
            max_bytes=max_bytes,
        )
  • RequestType type definition (Literal['http', 'dns', 'smtp', 'tcp']) used as the request_type parameter for wait_for_request tool to filter requests by type.
    RequestType = Literal["http", "dns", "smtp", "tcp"]
  • serialize_request function used by wait_for_request to convert request objects into dictionaries with optional body and raw data inclusion based on include_body and include_raw flags.
    def serialize_request(
        request: HttpRequest | DnsRequest | SmtpRequest | TcpRequest,
        *,
        include_raw: bool,
        include_body: bool,
        max_bytes: int,
    ) -> dict[str, Any]:
        payload: dict[str, Any] = {
            "id": request.id,
            "type": request.type,
            "uid": request.uid,
            "ip": request.ip,
            "country": request.country,
            "date_unix": request.date,
            "date_iso": _iso_from_unix(request.date),
        }
    
        if isinstance(request, HttpRequest):
            payload.update(
                {
                    "method": request.method,
                    "path": request.path,
                    "http_version": request.http_version,
                    "headers": request.headers,
                }
            )
            if include_body and request.body is not None:
                payload["body"] = bytes_envelope(request.body, max_bytes=max_bytes)
        elif isinstance(request, DnsRequest):
            payload.update(
                {
                    "port": request.port,
                    "query_type": request.query_type,
                    "domain": request.domain,
                    "reply": request.reply,
                }
            )
        elif isinstance(request, SmtpRequest):
            payload.update(
                {
                    "command": request.command,
                    "data": request.data,
                    "subject": request.subject,
                    "from_addr": request.from_addr,
                    "to": request.to,
                    "cc": request.cc,
                    "bcc": request.bcc,
                }
            )
        elif isinstance(request, TcpRequest):
            payload.update({"port": request.port})
    
        if include_raw:
            payload["raw"] = bytes_envelope(request.raw, max_bytes=max_bytes)
    
        return payload
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions polling and timeout, which implies a blocking or iterative operation, but fails to specify what constitutes a 'new request', how polling works (e.g., continuous checks), or potential side effects like resource consumption. This leaves key behavioral traits undocumented.

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

Conciseness5/5

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

The description is extremely concise with a single sentence, front-loading the core action ('Poll for a new request') and constraint ('until timeout'). There is no wasted text, making it efficient and easy to parse, though this brevity contributes to gaps in other dimensions.

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 the tool's complexity (polling with 6 parameters), no annotations, and an output schema (which helps but isn't described), the description is incomplete. It lacks details on behavior, parameter usage, and how it fits with siblings, making it insufficient for an agent to fully understand the tool's context and operation.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for all parameters. It only references 'timeout' implicitly, ignoring other parameters like 'request_type', 'poll_interval_seconds', 'include_raw', 'include_body', and 'max_bytes'. This adds minimal meaning beyond the schema, failing to explain their roles or interactions.

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 clearly states the action ('Poll for a new request') and the resource ('request'), making the purpose understandable. However, it doesn't distinguish this tool from sibling tools like 'list_requests' or 'get_shared_request', which might also involve requests, so it lacks explicit differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing an active session or specific conditions, nor does it compare to siblings like 'list_requests' for non-polling access, leaving usage context unclear.

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/hofill/RequestRepo-MCP'

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