dingtalk_notify_session_end
Send DingTalk notifications when coding sessions end, including duration, tasks completed, and statistics for team awareness.
Instructions
Send a session completion notification with automatic stats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sessionType | No | Type of session (e.g., "开发协助", "代码审查", "问题解决") | 开发协助 |
| duration | No | Session duration (e.g., "30分钟", "1小时20分") | |
| mainTasks | No | List of main tasks completed in this session | |
| summary | No | Brief summary of the session | 会话已完成 |
| filesCount | No | Number of files modified/created | |
| toolsUsed | No | Number of tools/commands used | |
| atAll | No | Whether to @all members |
Implementation Reference
- src/index.ts:326-387 (handler)The handler function that implements the dingtalk_notify_session_end tool. It constructs a detailed markdown message with session details, stats, tasks list, and sends it to DingTalk using the client.private async handleNotifySessionEnd(args: { sessionType?: string; duration?: string; mainTasks?: string[]; summary?: string; filesCount?: number; toolsUsed?: number; atAll?: boolean; }) { if (!this.dingTalkClient) { throw new Error('DingTalk client not configured. Use dingtalk_configure first or set environment variables (DINGTALK_WEBHOOK, DINGTALK_SECRET).'); } const sessionType = args.sessionType || '开发协助'; const duration = args.duration || '刚刚完成'; const mainTasks = args.mainTasks || []; const summary = args.summary || '会话已完成'; const filesCount = args.filesCount || 0; const toolsUsed = args.toolsUsed || 0; const now = new Date(); const gitUsername = this.getGitUsername(); const title = `🤖 Claude Code ${sessionType}完成`; let content = `## 🤖 Claude Code ${sessionType}完成 **完成时间:** ${now.toLocaleString('zh-CN')} **会话时长:** ${duration} **操作者:** ${gitUsername} ### 📋 本次会话 ${summary}`; if (mainTasks.length > 0) { content += ` ### ✅ 主要任务 ${mainTasks.map(task => `- ${task.trim()}`).join('\n')}`; } content += ` ### 📊 操作统计 - **文件操作:** ${filesCount} 个 - **工具使用:** ${toolsUsed} 次 --- *Claude Code 自动通知 | ${now.toLocaleDateString('zh-CN')}*`; const success = await this.dingTalkClient.sendMarkdown(title, content, args.atAll); return { content: [ { type: 'text', text: success ? '✅ Session completion notification sent successfully' : '❌ Failed to send session completion notification', }, ], }; }
- src/index.ts:153-196 (schema)Input schema definition for the tool, specifying optional parameters for session notification.{ name: 'dingtalk_notify_session_end', description: 'Send a session completion notification with automatic stats', inputSchema: { type: 'object', properties: { sessionType: { type: 'string', description: 'Type of session (e.g., "开发协助", "代码审查", "问题解决")', default: '开发协助' }, duration: { type: 'string', description: 'Session duration (e.g., "30分钟", "1小时20分")', }, mainTasks: { type: 'array', items: { type: 'string' }, description: 'List of main tasks completed in this session', }, summary: { type: 'string', description: 'Brief summary of the session', default: '会话已完成' }, filesCount: { type: 'number', description: 'Number of files modified/created', default: 0 }, toolsUsed: { type: 'number', description: 'Number of tools/commands used', default: 0 }, atAll: { type: 'boolean', description: 'Whether to @all members', default: false } }, required: [] }, },
- src/index.ts:218-227 (registration)Switch case in the CallToolRequest handler that routes the tool call to the specific handler method.case 'dingtalk_notify_session_end': return await this.handleNotifySessionEnd(args as unknown as { sessionType?: string; duration?: string; mainTasks?: string[]; summary?: string; filesCount?: number; toolsUsed?: number; atAll?: boolean; });