Skip to main content
Glama
msaelices

WhatsApp MCP Server

by msaelices

open_session

Initiate a new WhatsApp session using the WhatsApp MCP Server to enable interaction with the WhatsApp Business API, facilitating message sending and group management.

Instructions

Open a new WhatsApp session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary MCP tool handler for 'open_session', decorated with @mcp.tool() for registration, handles the tool execution by delegating to auth_manager.
    @mcp.tool()
    async def open_session(ctx: Context) -> str:
        """Open a new WhatsApp session."""
        try:
            # Open a new session
            success, message_text = await auth.auth_manager.open_session()
            if success:
                return f"Success: {message_text}"
            else:
                return f"Error: {message_text}"
        except Exception as e:
            logger.error(f"Error opening session: {e}")
            return f"Error: {str(e)}"
  • The core implementation logic for opening a WhatsApp session in the AuthManager class, initializes WhatsAppClient and manages session state.
    async def open_session(self) -> Tuple[bool, str]:
        """Open a new session."""
        if self.session:
            return False, "Session already exists"
    
        client = WhatsAppClient()
        success = await client.initialize()
    
        if success:
            self.session = client
            return True, "Session created successfully"
    
        return False, "Failed to create session"
  • Pydantic input schema model defined for the open_session tool (empty as tool takes no parameters).
    class CreateSessionModel(BaseModel):
        """Input schema for open_session tool."""
    
        pass
  • The @mcp.tool() decorator registers the open_session function as an MCP tool.
    @mcp.tool()
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 'Open a new WhatsApp session' implies initialization or connection, it lacks critical details: whether this requires credentials, if it's idempotent, what happens to existing sessions, potential side effects, or error conditions. This leaves significant behavioral gaps for a session management tool.

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 directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple tool and front-loaded with the essential information, making it easy for an agent to parse quickly.

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 complexity of session management (which often involves authentication, state persistence, and error handling), the description is insufficient. With no annotations, no output schema, and minimal behavioral context, it fails to provide complete guidance. The agent would need to guess about return values, success/failure states, and operational constraints.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of inputs. The description appropriately doesn't discuss parameters, maintaining focus on the tool's purpose without redundancy. A baseline of 4 is appropriate for zero-parameter tools when the schema coverage is complete.

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 ('Open') and target resource ('a new WhatsApp session'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its siblings like 'create_group' or 'send_message', which would require explicit differentiation for a perfect score.

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_chats' or 'send_message'. There's no mention of prerequisites (e.g., authentication status), timing considerations, or explicit exclusions, leaving the agent with minimal contextual direction.

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

Related 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/msaelices/whatsapp-mcp-server'

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