Skip to main content
Glama
Jem-HR
by Jem-HR

send_contact

Send contact cards via WhatsApp by specifying recipient, contact name, and phone number. Use this tool to share contact information directly in WhatsApp conversations.

Instructions

Send a contact card.

Args: to: Phone number or WhatsApp ID contact_name: Name of the contact contact_phone: Phone number of the contact reply_to_message_id: Message ID to reply to

Returns: Dictionary with success status and message ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYes
contact_nameYes
contact_phoneYes
reply_to_message_idNo

Implementation Reference

  • The main handler function for send_contact tool. It creates a Contact object with name and phone number, then calls wa_client.send_contact() to send the contact card via WhatsApp. Returns a dictionary with success status and message ID.
    @mcp.tool() async def send_contact( to: str, contact_name: str, contact_phone: str, *, reply_to_message_id: Optional[str] = None, ) -> dict: """ Send a contact card. Args: to: Phone number or WhatsApp ID contact_name: Name of the contact contact_phone: Phone number of the contact reply_to_message_id: Message ID to reply to Returns: Dictionary with success status and message ID """ try: # Create Contact object contact = Contact( name=Contact.Name(formatted_name=contact_name), phones=[Contact.Phone(phone=contact_phone)] ) result = wa_client.send_contact( to=to, contact=contact, reply_to_message_id=reply_to_message_id, ) logger.info(f"Contact sent to {to}") message_id = getattr(result, 'id', str(result)) if result else None return {"success": True, "message_id": message_id} except Exception as e: logger.error(f"Failed to send contact: {str(e)}") return {"success": False, "error": str(e)}
  • Schema definition for send_contact tool parameters and return type. Defines input parameters (to, contact_name, contact_phone, reply_to_message_id) with type hints and return type as dict.
    async def send_contact( to: str, contact_name: str, contact_phone: str, *, reply_to_message_id: Optional[str] = None, ) -> dict:
  • Tool registration using @mcp.tool() decorator. This decorator registers the send_contact function as an available MCP tool.
    @mcp.tool()
  • Registration function that calls register_messaging_tools to register all messaging tools including send_contact.
    def register_all_tools(mcp, wa_client): """Register all available tools with the MCP server.""" register_messaging_tools(mcp, wa_client) register_interactive_tools(mcp, wa_client) register_template_tools(mcp, wa_client)
  • server.py:68-68 (registration)
    Main entry point where all tools are registered with the MCP server by calling register_all_tools.
    register_all_tools(mcp, client)

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/Jem-HR/pywa-mcp-server'

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