Skip to main content
Glama

create_message

Send messages in Webex rooms by specifying room ID, text, or attachments. Supports replies, markdown formatting, and file attachments for effective communication.

Instructions

Create a message in a Webex room.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
attachmentsNoAn array of attachment objects.
filesNoAn array of file URLs to attach to the message.
markdownNoThe message in markdown format.
parentIdNoThe ID of the parent message (if this is a reply).
roomIdYesThe ID of the room where the message will be sent.
textYesThe plain text message to send.
toPersonEmailNoThe email of the person to whom the message is directed.
toPersonIdNoThe ID of the person to whom the message is directed.

Implementation Reference

  • The executeFunction that implements the core logic of the 'create_message' tool. It constructs a payload from input parameters and sends a POST request to the Webex /messages endpoint using fetch, handling errors and returning the API response.
    const executeFunction = async ({ roomId, parentId, toPersonId, toPersonEmail, text, markdown, files = [], attachments = [] }) => { try { // Debug: Log received parameters console.error('[DEBUG] create-a-message received parameters:', { roomId, parentId, toPersonId, toPersonEmail, text, markdown, files, attachments }); // Construct the message payload (only include defined parameters) const payload = {}; if (roomId) payload.roomId = roomId; if (parentId) payload.parentId = parentId; if (toPersonId) payload.toPersonId = toPersonId; if (toPersonEmail) payload.toPersonEmail = toPersonEmail; if (text) payload.text = text; if (markdown) payload.markdown = markdown; if (files && files.length > 0) payload.files = files; if (attachments && attachments.length > 0) payload.attachments = attachments; // Get the API URL and headers using the centralized config const url = getWebexUrl('/messages'); const headers = getWebexJsonHeaders(); // Perform the fetch request const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify(payload) }); // Check if the response was successful if (!response.ok) { const errorText = await response.text(); let errorMessage = `HTTP ${response.status}: ${response.statusText}`; try { const errorData = JSON.parse(errorText); errorMessage = errorData.message || errorData.error || JSON.stringify(errorData); } catch (e) { errorMessage = errorText || errorMessage; } throw new Error(errorMessage); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error creating message:', error); return { error: error.message || 'An error occurred while creating the message.', details: error.stack }; } };
  • The JSON schema definition for the 'create_message' tool, including input parameters with types, descriptions, and required fields.
    type: 'function', function: { name: 'create_message', description: 'Create a message in a Webex room.', parameters: { type: 'object', properties: { roomId: { type: 'string', description: 'The ID of the room where the message will be sent.' }, parentId: { type: 'string', description: 'The ID of the parent message (if this is a reply).' }, toPersonId: { type: 'string', description: 'The ID of the person to whom the message is directed.' }, toPersonEmail: { type: 'string', description: 'The email of the person to whom the message is directed.' }, text: { type: 'string', description: 'The plain text message to send.' }, markdown: { type: 'string', description: 'The message in markdown format.' }, files: { type: 'array', items: { type: 'string' }, description: 'An array of file URLs to attach to the message.' }, attachments: { type: 'array', items: { type: 'object' }, description: 'An array of attachment objects.' } }, required: ['text'] } } }
  • The apiTool constant that bundles the handler function and schema definition, exported for use in tool registration (likely loaded dynamically in the MCP server).
    const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'create_message', description: 'Create a message in a Webex room.', parameters: { type: 'object', properties: { roomId: { type: 'string', description: 'The ID of the room where the message will be sent.' }, parentId: { type: 'string', description: 'The ID of the parent message (if this is a reply).' }, toPersonId: { type: 'string', description: 'The ID of the person to whom the message is directed.' }, toPersonEmail: { type: 'string', description: 'The email of the person to whom the message is directed.' }, text: { type: 'string', description: 'The plain text message to send.' }, markdown: { type: 'string', description: 'The message in markdown format.' }, files: { type: 'array', items: { type: 'string' }, description: 'An array of file URLs to attach to the message.' }, attachments: { type: 'array', items: { type: 'object' }, description: 'An array of attachment objects.' } }, required: ['text'] } } } }; export { apiTool };
  • Import of helper functions getWebexUrl and getWebexJsonHeaders from lib/webex-config.js, used to obtain the API endpoint and authorization headers.
    import { getWebexUrl, getWebexJsonHeaders } from '../../../lib/webex-config.js';

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/Kashyap-AI-ML-Solutions/webex-messaging-mcp-server'

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