Skip to main content
Glama
sfyyy

Claude Code DingTalk MCP Server

by sfyyy

dingtalk_notify_session_end

Send session completion notifications via DingTalk, including session type, duration, tasks completed, summary, file modifications, tools used, and optional @all mentions.

Instructions

Send a session completion notification with automatic stats

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
atAllNoWhether to @all members
durationNoSession duration (e.g., "30分钟", "1小时20分")
filesCountNoNumber of files modified/created
mainTasksNoList of main tasks completed in this session
sessionTypeNoType of session (e.g., "开发协助", "代码审查", "问题解决")开发协助
summaryNoBrief summary of the session会话已完成
toolsUsedNoNumber of tools/commands used

Implementation Reference

  • The main handler function that constructs a detailed markdown message for session completion notification, including stats like duration, tasks, files, tools, and sends it via the DingTalk 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 (registration)
    Tool registration in the ListToolsRequest handler, defining the tool name, description, and input schema.
    { 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-228 (registration)
    Dispatch registration in the CallToolRequest handler's switch statement, casting arguments and calling the handler.
    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; });
  • Input schema definition for the tool's parameters.
    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: []
  • Helper function to retrieve the git username, used in the notification message.
    private getGitUsername(): string { try { const username = execSync('git config --get user.name', { encoding: 'utf8' }).trim(); return username || 'Unknown User'; } catch (error) { return 'Unknown User'; }

Other Tools

Related 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/sfyyy/claude-code-dingtalk-mcp'

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