Skip to main content
Glama
PhononX

Carbon Voice

by PhononX

summarize_conversation

Generate concise summaries of Carbon Voice conversations to extract key information and insights from message exchanges.

Instructions

Summarize a conversation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idYes
prompt_idYes
message_idsNo
languageNo
start_dateNo
end_dateNo
limitNo

Implementation Reference

  • src/server.ts:487-529 (registration)
    Full registration of the 'summarize_conversation' tool, including the inline anonymous handler function that implements the tool's logic by fetching messages if necessary and calling the AI response API to generate a summary.
    server.registerTool(
      'summarize_conversation',
      {
        description: 'Summarize a conversation.',
        inputSchema: summarizeConversationParams.shape,
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
        },
      },
      async (
        args: SummarizeConversationParams,
        { authInfo },
      ): Promise<McpToolResponse> => {
        try {
          let message_ids: string[] = args.message_ids || [];
    
          // If no message ids are provided, get couple of messages from the conversation
          if (!args.message_ids) {
            const messages = await simplifiedApi.listMessages(
              args,
              setCarbonVoiceAuthHeader(authInfo?.token),
            );
            message_ids = messages.results?.map((message) => message.id) || [];
          }
    
          const aiResponse = await simplifiedApi.aIResponseControllerCreateResponse(
            {
              prompt_id: args.prompt_id,
              message_ids: message_ids,
              channel_id: args.conversation_id,
              language: args.language,
            },
            setCarbonVoiceAuthHeader(authInfo?.token),
          );
    
          return formatToMCPToolResponse(aiResponse);
        } catch (error) {
          logger.error('Error summarizing conversation:', { error });
          return formatToMCPToolResponse(error);
        }
      },
    );
  • The anonymous async handler function that executes the core logic of the summarize_conversation tool: conditionally lists recent messages from the conversation, then invokes the AI response controller with a specific prompt to generate the summary.
    async (
      args: SummarizeConversationParams,
      { authInfo },
    ): Promise<McpToolResponse> => {
      try {
        let message_ids: string[] = args.message_ids || [];
    
        // If no message ids are provided, get couple of messages from the conversation
        if (!args.message_ids) {
          const messages = await simplifiedApi.listMessages(
            args,
            setCarbonVoiceAuthHeader(authInfo?.token),
          );
          message_ids = messages.results?.map((message) => message.id) || [];
        }
    
        const aiResponse = await simplifiedApi.aIResponseControllerCreateResponse(
          {
            prompt_id: args.prompt_id,
            message_ids: message_ids,
            channel_id: args.conversation_id,
            language: args.language,
          },
          setCarbonVoiceAuthHeader(authInfo?.token),
        );
    
        return formatToMCPToolResponse(aiResponse);
      } catch (error) {
        logger.error('Error summarizing conversation:', { error });
        return formatToMCPToolResponse(error);
      }
    },
  • Zod schema defining the input parameters for the summarize_conversation tool, including conversation_id, prompt_id, optional message_ids, language, date ranges, and limit.
    export const summarizeConversationParams = z.object({
      conversation_id: z.string().nonempty(),
      prompt_id: z.string().nonempty(),
      message_ids: z.array(z.string()).optional(),
      language: z.string().optional(),
      start_date: z.string().datetime().optional(),
      end_date: z.string().datetime().optional(),
      limit: z.number().optional().default(50),
    });
  • TypeScript type definition for SummarizeConversationParams, inferred from the Zod schema for type safety in the handler.
    export type SummarizeConversationParams = z.infer<
      typeof summarizeConversationParams
    >;

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/PhononX/cv-mcp-server'

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