get_recent_messages
Retrieve the 10 most recent messages from Carbon Voice, including details like Conversation, Creator, and Labels. Optional filters: conversation_id and language for targeted results.
Instructions
Get most recent messages, including their associated Conversation, Creator, and Labels information. Returns a maximum of 10 messages.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| conversation_id | No | Conversation ID (optional) | |
| language | No | Language (optional) - Original language will be used if not provided or not found. |
Implementation Reference
- src/server.ts:165-180 (handler)The handler function that executes the logic for the 'get_recent_messages' tool. It calls the Carbon Voice Simplified API's getTenRecentMessagesResponse method with the input arguments and authentication header, formats the response using formatToMCPToolResponse, and handles any errors by logging and returning a formatted error response.async ( args: GetTenRecentMessagesResponseParams, { authInfo }, ): Promise<McpToolResponse> => { try { return formatToMCPToolResponse( await simplifiedApi.getTenRecentMessagesResponse( args, setCarbonVoiceAuthHeader(authInfo?.token), ), ); } catch (error) { logger.error('Error getting recent messages:', { args, error }); return formatToMCPToolResponse(error); } },
- src/server.ts:153-181 (registration)The registration of the 'get_recent_messages' tool with the MCP server, specifying the tool name, description, input schema (from generated Zod schemas), annotations, and references the handler function.server.registerTool( 'get_recent_messages', { description: 'Get most recent messages, including their associated Conversation, Creator, and Labels information. ' + 'Returns a maximum of 10 messages.', inputSchema: getTenRecentMessagesResponseQueryParams.shape, annotations: { readOnlyHint: true, destructiveHint: false, }, }, async ( args: GetTenRecentMessagesResponseParams, { authInfo }, ): Promise<McpToolResponse> => { try { return formatToMCPToolResponse( await simplifiedApi.getTenRecentMessagesResponse( args, setCarbonVoiceAuthHeader(authInfo?.token), ), ); } catch (error) { logger.error('Error getting recent messages:', { args, error }); return formatToMCPToolResponse(error); } }, );
- The Zod schema defining the input parameters for the underlying API endpoint getTenRecentMessagesResponse, used as the inputSchema for the MCP tool. Supports optional conversation_id and language filters.export const getTenRecentMessagesResponseQueryParams = zod.object({ "conversation_id": zod.string().optional().describe('Conversation ID (optional)'), "language": zod.string().optional().describe('Language (optional) - Original language will be used if not provided or not found.') })
- The Zod schema defining the output response structure for the getTenRecentMessagesResponse API endpoint, which includes up to 10 recent messages with associated message details, creator, conversation, and labels information.export const getTenRecentMessagesResponseResponse = zod.object({ "results": zod.array(zod.object({ "message": zod.object({ "id": zod.string().describe('ID'), "name": zod.string().optional().describe('Name'), "link": zod.string().describe('Link to Message'), "creator_id": zod.string().describe('Creator ID'), "conversation_id": zod.string().optional().describe('Conversation ID'), "workspace_id": zod.string().optional().describe('Workspace ID'), "created_at": zod.string().datetime({}), "last_updated_at": zod.string().datetime({}), "deleted_at": zod.string().datetime({}).optional(), "duration_ms": zod.number().describe('The length of the message in milliseconds'), "audio_url": zod.string().optional().describe('The URL for the message audio file'), "audio_stream_url": zod.string().optional().describe('The URL for the message audio stream'), "transcript": zod.string().optional().describe('Transcript of the message'), "ai_summary": zod.string().optional().describe('AI Summary generated of the message'), "waveform_url": zod.string().optional().describe('The URL for the message waveform image'), "reply_count": zod.number().describe('The number of replies to the message'), "parent_message_id": zod.string().optional().describe('Parent Message unique ID (only available for replies)'), "language": zod.string().default(getTenRecentMessagesResponseResponseResultsItemMessageLanguageDefault).describe('Language for the message (Transcript, AI summary, Audio...)'), "status": zod.enum(['offline', 'paused', 'processing', 'scheduled', 'active', 'deleted', 'account-deleted', 'initializing', 'inprogress', 'canceled', 'failed']).describe('Current status of the Message'), "type": zod.enum(['channel', 'prerecorded', 'voicememo', 'stored', 'welcome']).describe('Type of the Message'), "attachments": zod.array(zod.object({ "id": zod.string(), "creator_id": zod.string(), "created_at": zod.string().datetime({}), "type": zod.enum(['link', 'file', 'location', 'ai-response-id', 'ai-prompt-id']), "link": zod.string(), "active_begin": zod.string().datetime({}).optional(), "active_end": zod.string().datetime({}).optional(), "filename": zod.string().optional(), "mime_type": zod.string().optional(), "length_in_bytes": zod.number().optional(), "location": zod.object({ }).optional() })).optional().describe('List of attachments for the message'), "share_link_id": zod.string().optional().describe('Share Link ID to a message'), "folder_id": zod.string().optional().describe('Folder ID where the message is stored') }), "creator": zod.object({ "id": zod.string().describe(' ID'), "link": zod.string().describe('Link to User'), "created_at": zod.string().datetime({}), "first_name": zod.string().describe('First Name'), "last_name": zod.string().optional().describe('Last Name'), "full_name": zod.string().describe('Full Name'), "image_url": zod.string().optional().describe('Image Url'), "emails": zod.array(zod.string()).optional().describe('List of emails (First one is the primary)'), "phones": zod.array(zod.string()).optional().describe('List of phones (First one is the primary)'), "languages": zod.array(zod.string()).optional().describe('List of languages (First one is the primary)') }).optional(), "conversation": zod.object({ "id": zod.string().describe('ID'), "link": zod.string().describe('Link to Conversation'), "name": zod.string().describe('Name'), "description": zod.string().optional().describe('Description'), "workspace_id": zod.string().describe('Workspace ID'), "workspace_name": zod.string().describe('Workspace Name'), "workspace_image_url": zod.string().optional().describe('Workspace Image Url'), "owner_id": zod.string().describe('owner unique ID'), "type": zod.enum(['directMessage', 'customerConversation', 'namedConversation', 'asyncMeeting']).describe('Type'), "visibility": zod.enum(['private', 'workspace', 'public']).describe('Visibility'), "total_messages": zod.number().describe('Total Messages'), "total_duration_ms": zod.number().describe('Total duration in milliseconds'), "image_url": zod.string().optional().describe('Image Url'), "is_private": zod.boolean().describe('Is Private Conversation'), "is_async": zod.boolean().describe('Is Async Conversation'), "async_stats": zod.object({ "stats": zod.object({ "total_duration_milliseconds": zod.number().describe('Total duration in milliseconds'), "total_heard_milliseconds": zod.number().describe('Total heard in milliseconds'), "total_engaged_percentage": zod.number().describe('Total engaged percentage'), "total_messages_posted": zod.number().describe('Total messages posted'), "total_users": zod.number().describe('Total users') }).describe('Conversation stats'), "user_stats": zod.array(zod.object({ "user_id": zod.string().describe('User unique ID'), "total_messages_posted": zod.number().describe('Total messages posted'), "total_sent_milliseconds": zod.number().describe('Total sent in milliseconds'), "total_heard_milliseconds": zod.number().describe('Total heard in milliseconds'), "total_engaged_percentage": zod.number().describe('Total engaged percentage'), "total_heard_messages": zod.number().describe('Total heard messages'), "total_unheard_messages": zod.number().describe('Total unheard messages') })).describe('User stats') }).optional().describe('Async Meeting Stats'), "created_at": zod.string().datetime({}), "last_updated_at": zod.string().datetime({}), "deleted_at": zod.string().datetime({}).optional() }).optional(), "labels": zod.array(zod.object({ "id": zod.string().describe('ID'), "name": zod.string().describe('Name'), "behavior": zod.enum(['removeOnListenStart', 'removeWhenHeard', 'persistent']).describe('Behavior'), "type": zod.enum(['personal', 'workspace', 'system', 'reaction']).describe('Type'), "creator_guid": zod.string().describe('Creator ID'), "space_guid": zod.string().optional().describe('Workspace ID'), "image_url": zod.string().optional().describe('Image URL'), "automatic_playlist": zod.boolean().optional().describe('Automatic Playlist'), "sort_order": zod.number().optional().describe('Sort Order') })).optional() })).optional().describe('List of 10 recent messages') })