send_message
Send messages directly to Google Chat spaces using the tool within the Google Workspace MCP Server. Specify user details, space ID, and message text for effective communication.
Instructions
Sends a message to a Google Chat space.
Returns:
str: Confirmation message with sent message details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message_text | Yes | ||
| service | Yes | ||
| space_id | Yes | ||
| thread_key | No | ||
| user_google_email | Yes |
Implementation Reference
- gchat/chat_tools.py:117-153 (handler)The core handler function `send_message` that sends a text message to a specified Google Chat space using the Google Chat API service. It supports optional thread_key for threaded replies and returns a confirmation with message ID and timestamp.async def send_message( service, user_google_email: str, space_id: str, message_text: str, thread_key: Optional[str] = None ) -> str: """ Sends a message to a Google Chat space. Returns: str: Confirmation message with sent message details. """ logger.info(f"[send_message] Email: '{user_google_email}', Space: '{space_id}'") message_body = { 'text': message_text } # Add thread key if provided (for threaded replies) request_params = { 'parent': space_id, 'body': message_body } if thread_key: request_params['threadKey'] = thread_key message = await asyncio.to_thread( service.spaces().messages().create(**request_params).execute ) message_name = message.get('name', '') create_time = message.get('createTime', '') msg = f"Message sent to space '{space_id}' by {user_google_email}. Message ID: {message_name}, Time: {create_time}" logger.info(f"Successfully sent message to space '{space_id}' by {user_google_email}") return msg
- gchat/chat_tools.py:114-114 (registration)Registers the `send_message` tool in the MCP server registry using the `@server.tool()` decorator.@server.tool()
- gchat/chat_tools.py:117-123 (schema)Input schema defined by function parameters: service (inferred), user_google_email: str, space_id: str, message_text: str, thread_key: Optional[str] = None. Output: str confirmation.async def send_message( service, user_google_email: str, space_id: str, message_text: str, thread_key: Optional[str] = None ) -> str: