Skip to main content
Glama

log_conversation

Log AI conversations by recording user requests, execution plans, and summaries in structured format for searchable history and project continuity.

Instructions

记录AI对话 - 所有会话都要记录

使用规范: • userRequest: 用户原始需求+上传文件说明 • aiTodoList: 你的执行计划清单(即使只是查看也要列出) • aiSummary: 你的操作总结(3-5句话,包括解释、分析等) • fileOperations: 文件操作总结,格式:"动作 文件路径 - 说明"(可为空) • title: 对话标题(可选) • tags: 标签数组(可选)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userRequestYes用户原始需求 + 上传文件说明
aiTodoListYesAI的执行计划清单(即使只是查看也要列出)
aiSummaryYesAI的操作总结(3-5句话,包括解释、分析等)
fileOperationsNo文件操作总结,格式:"动作 文件路径 - 说明"(可为空)
titleNo对话标题(可选)
tagsNo标签数组(可选)
projectNo项目名(可选,自动检测)

Implementation Reference

  • The logConversation method implements the core tool logic: validates parameters, auto-detects project, generates conversation entry, appends to daily Markdown log file, and returns formatted success or error response.
    async logConversation(params: unknown): Promise<{ content: Array<{ type: string; text: string }> }> {
      try {
        const validatedParams = validateLogConversation(params);
        const {
          userRequest,
          aiTodoList,
          aiSummary,
          fileOperations,
          title,
          tags,
          platform
        } = validatedParams;
    
        // Auto-detect project from current working directory
        const projectInfo = await this.fileManager.getProjectInfo();
        const projectName = projectInfo.name;
    
        await this.fileManager.initializeProject();
    
        const now = new Date();
        // Use zero-padded date format for better sorting (2025-08-07 instead of 2025-8-7)
        const year = now.getFullYear();
        const month = String(now.getMonth() + 1).padStart(2, '0');
        const day = String(now.getDate()).padStart(2, '0');
        const dateStr = `${year}-${month}-${day}`;
        const conversationEntry: ConversationEntry = {
          id: randomUUID(),
          timestamp: now.toISOString(),
          project: projectName,
          platform: platform || CONSTANTS.PLATFORMS.UNKNOWN,
          userRequest: userRequest.trim(),
          aiTodoList: aiTodoList || [],
          aiSummary: aiSummary.trim(),
          fileOperations: fileOperations || [],
          title: title?.trim() || undefined,
          tags: tags || []
        };
    
        const dailyLogPath = await this.fileManager.getDailyLogPath(projectName, dateStr);
        let existingContent = await this.fileManager.readFile(dailyLogPath);
        
        // Calculate conversation number
        const existingConversationCount = (existingContent.match(/## 对话/g) || []).length;
        const conversationNumber = existingConversationCount + 1;
        
        // Generate the conversation markdown
        const conversationMarkdown = MarkdownFormatter.formatConversationEntry(conversationEntry, conversationNumber);
        
        if (!existingContent) {
          // New file: create header + new conversation
          const header = MarkdownFormatter.formatDailyLogHeader(projectName, dateStr, projectInfo.root);
          const finalContent = header + conversationMarkdown;
          await this.fileManager.writeFile(dailyLogPath, finalContent);
        } else {
          // Existing file: just append new conversation
          const finalContent = existingContent + conversationMarkdown;
          await this.fileManager.writeFile(dailyLogPath, finalContent);
        }
    
        return {
          content: [
            {
              type: 'text',
              text: `✅ 对话已成功记录到项目 "${projectName}"!\n\n` +
                    `📁 文件位置: ${dailyLogPath}\n` +
                    `💻 项目目录: ${projectInfo.root || '未检测到项目'}\n` +
                    `🕒 时间: ${now.toLocaleString('zh-CN')}\n` +
                    `🏷️ 标签: ${(tags && tags.length > 0) ? tags.join(', ') : '无'}\n` +
                    `⚡ 执行任务: ${aiTodoList?.length || 0}\n` +
                    `📂 文件操作: ${fileOperations?.length || 0}\n` +
                    `📝 对话编号: 对话${conversationNumber}`
            }
          ]
        };
      } catch (error) {
        const errorMessage = error instanceof ValidationError 
          ? `参数验证失败: ${error.message}`
          : error instanceof FileOperationError
          ? `文件操作失败: ${error.message} (文件: ${error.filePath})`
          : `记录对话时出错: ${String(error)}`;
        
        return {
          content: [
            {
              type: 'text',
              text: `❌ ${errorMessage}`
            }
          ]
        };
      }
    }
  • Zod schema for validating input parameters of the log_conversation tool, including transformation for defaults.
    export const LogConversationSchema = z.object({
      project: z.string().optional(),  // 项目名称(可选,自动检测)
      userRequest: z.string().min(1, '用户需求不能为空'),
      aiTodoList: z.array(z.string()).min(1, 'AI执行计划不能为空'),
      aiSummary: z.string().min(1, 'AI总结不能为空'),
      fileOperations: z.array(z.string()).optional(),
      title: z.string().optional(),
      tags: z.array(z.string()).optional(),
      platform: z.string().default(CONSTANTS.PLATFORMS.CLAUDE_CODE)
    }).transform((data) => ({
      ...data,
      tags: data.tags || [],
      fileOperations: data.fileOperations || [],
      platform: data.platform || CONSTANTS.PLATFORMS.CLAUDE_CODE
    }));
  • src/index.ts:38-78 (registration)
    MCP tool registration: defines the 'log_conversation' tool specification including name, description, and input schema in the ListTools response.
    {
      name: 'log_conversation',
      description: '记录AI对话 - 所有会话都要记录\n\n使用规范:\n• userRequest: 用户原始需求+上传文件说明\n• aiTodoList: 你的执行计划清单(即使只是查看也要列出)\n• aiSummary: 你的操作总结(3-5句话,包括解释、分析等)\n• fileOperations: 文件操作总结,格式:"动作 文件路径 - 说明"(可为空)\n• title: 对话标题(可选)\n• tags: 标签数组(可选)',
      inputSchema: {
        type: 'object',
        properties: {
          userRequest: {
            type: 'string',
            description: '用户原始需求 + 上传文件说明'
          },
          aiTodoList: {
            type: 'array',
            items: { type: 'string' },
            description: 'AI的执行计划清单(即使只是查看也要列出)'
          },
          aiSummary: {
            type: 'string',
            description: 'AI的操作总结(3-5句话,包括解释、分析等)'
          },
          fileOperations: {
            type: 'array',
            items: { type: 'string' },
            description: '文件操作总结,格式:"动作 文件路径 - 说明"(可为空)'
          },
          title: {
            type: 'string',
            description: '对话标题(可选)'
          },
          tags: {
            type: 'array',
            items: { type: 'string' },
            description: '标签数组(可选)'
          },
          project: {
            type: 'string',
            description: '项目名(可选,自动检测)'
          }
        },
        required: ['userRequest', 'aiTodoList', 'aiSummary']
      }
    },
  • src/index.ts:161-162 (registration)
    Dispatch handler in CallToolRequest that routes 'log_conversation' calls to the ConversationLogger instance.
    case 'log_conversation':
      return await this.conversationLogger.logConversation(args || {});
  • Validator function for log_conversation parameters using the Zod schema, throws error on invalid input.
    export const validateLogConversation = (data: unknown): LogConversationParams => {
      const result = LogConversationSchema.safeParse(data);
      if (!result.success) {
        const errorMessages = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`).join('; ');
        throw new Error(`${CONSTANTS.ERROR_MESSAGES.INVALID_PARAMETERS}: ${errorMessages}`);
      }
      return result.data as LogConversationParams;
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly indicates this is a logging/write operation ('记录'), but doesn't specify persistence characteristics, potential side effects, error conditions, or what happens after logging. The description adds some behavioral context through the usage guidelines, but doesn't fully describe the tool's behavior beyond the basic logging action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear purpose statement followed by organized usage guidelines. It's appropriately sized for a 7-parameter tool with detailed requirements. Every sentence serves a purpose, though the Chinese text could potentially be more concise in some sections. The information is front-loaded with the core purpose first.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a logging tool with 7 parameters, no annotations, and no output schema, the description provides good parameter guidance but lacks information about what happens after logging. It doesn't specify return values, success/failure indicators, or how the logged data can be retrieved later. The usage guidelines are comprehensive for input preparation, but the overall context of the logging operation is incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds value by providing usage guidelines that explain the purpose and format expectations for each parameter (e.g., '3-5句话' for aiSummary, specific format for fileOperations). This goes beyond the schema's basic descriptions and provides practical guidance for parameter usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '记录AI对话 - 所有会话都要记录' (Log AI conversations - all conversations must be logged). This is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'search_conversations' or explain how this logging tool relates to those search/retrieval tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidelines with a '使用规范' section that details when and how to use this tool. It specifies required parameters and their purposes, and the statement '所有会话都要记录' (all conversations must be logged) gives clear context about when this tool should be invoked. No explicit alternatives are mentioned, but the guidelines are comprehensive for this specific logging operation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/fablefang/ai-conversation-logger-mcp'

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