Skip to main content
Glama

list_recent_chats

Retrieve recent WhatsApp conversations to monitor chat activity and manage ongoing discussions through automated browser access.

Instructions

List the most recent chats visible in WhatsApp Web.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • The `list_recent_chats` handler in `WhatsAppClient` class, which uses Playwright to scrape chat information from the DOM.
    async def list_recent_chats(self, limit: int = 20) -> dict[str, Any]:
        await self._require_ready()
        assert self._page is not None
    
        await self._page.goto(self.settings.base_url, wait_until="domcontentloaded")
        await self._page.wait_for_selector(READY_SELECTORS[0])
        chats = await self._page.evaluate(
            """(limit) => {
                const rows = Array.from(document.querySelectorAll('#pane-side [role="listitem"]')).slice(0, limit);
                return rows.map((row, index) => {
                    const title = row.querySelector('[title]')?.getAttribute('title') || null;
                    const preview = row.innerText ? row.innerText.split('\\n').slice(0, 4).join(' | ') : null;
                    return { index, title, preview };
                });
            }""",
            limit,
        )
        return {"count": len(chats), "chats": chats}
  • Registration of the `list_recent_chats` tool in the `WhatsAppMCPServer` class, mapping the tool to its handler.
    "list_recent_chats": ToolDefinition(
        name="list_recent_chats",
        description="List the most recent chats visible in WhatsApp Web.",
        input_schema={
            "type": "object",
            "properties": {
                "limit": {"type": "integer", "minimum": 1, "maximum": 100, "default": 20},
            },
            "additionalProperties": False,
        },
        handler=lambda args: self.client.list_recent_chats(args.get("limit", 20)),
    ),
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While it implies a read-only operation ('List'), it doesn't specify whether this requires authentication, what happens if WhatsApp Web isn't loaded, whether there are rate limits, or what format the output takes. The description provides minimal behavioral context beyond the basic action.

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 a single, efficient sentence that states the core purpose without unnecessary words. It's appropriately sized for a simple tool and gets straight to the point with zero waste.

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?

For a tool with no annotations, no output schema, and incomplete parameter documentation, the description is insufficient. It doesn't explain what 'recent' means, how results are ordered, what data is returned, or any error conditions. Given the complexity of interacting with WhatsApp Web, more context is needed for an agent to use this effectively.

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?

The schema has 0% description coverage, so the description must compensate. However, the description mentions no parameters at all, while the schema shows one optional 'limit' parameter. The description doesn't add any parameter semantics beyond what's already in the schema structure. Baseline 3 is appropriate since the schema provides the parameter definition.

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 ('List') and resource ('most recent chats visible in WhatsApp Web'), making the purpose immediately understandable. However, it doesn't distinguish this tool from sibling 'get_recent_messages', which could be confusing for an agent trying to choose between them.

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 like 'get_recent_messages' or 'get_auth_status'. There's no mention of prerequisites (like needing authentication), nor any context about what 'recent' means or how this differs from other chat-related tools.

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/ekaksher/whatsapp-mcp'

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